// Token: 0x06000CA6 RID: 3238 RVA: 0x00043E44 File Offset: 0x00042044
        internal void DeserializeData(BinaryReader reader, ComponentDataPool componentDataPool)
        {
            StringData stringDataInstance = componentDataPool.GetStringDataInstance();

            stringDataInstance.DeserializeData(reader, componentDataPool);
            if (string.IsNullOrEmpty(stringDataInstance.Data))
            {
                throw new CorruptSyncStateException(new LocalizedString("[MeetingOrganizerEntry.DeserializeData] deserialized Uid was null or empty."), null);
            }
            this.CleanGlobalObjectId = new GlobalObjectId(stringDataInstance.Data);
            DateTimeData dateTimeDataInstance = componentDataPool.GetDateTimeDataInstance();

            dateTimeDataInstance.DeserializeData(reader, componentDataPool);
            this.EntryTime = (DateTime)dateTimeDataInstance.Data;
            StringData stringDataInstance2 = componentDataPool.GetStringDataInstance();

            stringDataInstance2.DeserializeData(reader, componentDataPool);
            this.Organizer = stringDataInstance2.Data;
            NullableData <BooleanData, bool> nullableData = new NullableData <BooleanData, bool>();

            nullableData.DeserializeData(reader, componentDataPool);
            this.IsOrganizer = nullableData.Data;
            StringData stringDataInstance3 = componentDataPool.GetStringDataInstance();

            stringDataInstance3.DeserializeData(reader, componentDataPool);
            this.Subject = stringDataInstance3.Data;
        }
Пример #2
0
        private static void AddInitialData()
        {
            DatabaseContext db = new DatabaseContext();

            if (db.Users.Any() == false)
            {
                db.Users.Add(new User {
                    Username = "******", Password = "******"
                });
                db.SaveChanges();
            }

            if (db.Expenses.Any() == false)
            {
                string[] categories = new string[] { "Market", "Elektronik", "Tatil", "Taký" };
                int      userId     = db.Users.FirstOrDefault().Id;

                for (int i = 0; i < 50; i++)
                {
                    db.Expenses.Add(new Expense
                    {
                        Category    = CollectionData.GetElement(categories),
                        Date        = DateTimeData.GetDatetime(),
                        Description = TextData.GetSentence(),
                        Price       = NumberData.GetNumber(100, 500),
                        UserId      = userId
                    });
                }

                db.SaveChanges();
            }
        }
Пример #3
0
        public dynamic GetReportData()
        {
            // Generating employee list
            var employees = Enumerable
                            .Range(0, NumberData.GetNumber(10, 50))
                            .Select(i =>
            {
                dynamic newEmployee         = new ExpandoObject();
                newEmployee.BirthDate       = DateTimeData.GetDatetime(new DateTime(1973, 1, 1), new DateTime(1997, 12, 1));
                newEmployee.FirstName       = NameData.GetFirstName();
                newEmployee.LastName        = NameData.GetSurname();
                newEmployee.Company         = NameData.GetCompanyName();
                newEmployee.Email           = NetworkData.GetEmail();
                newEmployee.PhoneNumber     = PhoneNumberData.GetInternationalPhoneNumber();
                newEmployee.Address         = string.Format("{0} {1} {2}\n{3},{4} {5}", PlaceData.GetStreetName(), PlaceData.GetStreetNumber(), PlaceData.GetAddress(), PlaceData.GetCity(), PlaceData.GetState(), PlaceData.GetZipCode());
                newEmployee.PersonalQuote   = TextData.GetSentences(5);
                newEmployee.PorfileFileName = $"{FakeData.NumberData.GetNumber(0,7)}.png";
                // NOTE: Even though ExpandoObject is compatible with IDictionary<string,object>,
                //       The template engine only accepts Dictionary<string,object>
                return(new Dictionary <string, object>(newEmployee));
            })
                            .ToList();

            dynamic reportData = new ExpandoObject();

            reportData.Employees = employees;
            return(reportData);
        }
        public void SerializeData(BinaryWriter writer, ComponentDataPool componentDataPool)
        {
            GenericDictionaryData <DerivedData <RecipientInfoCacheSyncItemId>, RecipientInfoCacheSyncItemId, Int64Data, long> genericDictionaryData = new GenericDictionaryData <DerivedData <RecipientInfoCacheSyncItemId>, RecipientInfoCacheSyncItemId, Int64Data, long>();

            genericDictionaryData.Bind(this.cacheEntryIdToLastUpdateTime).SerializeData(writer, componentDataPool);
            DateTimeData dateTimeData = new DateTimeData(this.LastModifiedTime);

            dateTimeData.SerializeData(writer, componentDataPool);
        }
            public void DeserializeData(BinaryReader reader, ComponentDataPool componentDataPool)
            {
                this.calendarItem = reader.ReadBoolean();
                DateTimeData dateTimeDataInstance = componentDataPool.GetDateTimeDataInstance();

                dateTimeDataInstance.DeserializeData(reader, componentDataPool);
                this.endTime           = dateTimeDataInstance.Data;
                this.recurring         = reader.ReadBoolean();
                this.doesRecurrenceEnd = reader.ReadBoolean();
            }
        public void DeserializeData(BinaryReader reader, ComponentDataPool componentDataPool)
        {
            GenericDictionaryData <DerivedData <RecipientInfoCacheSyncItemId>, RecipientInfoCacheSyncItemId, Int64Data, long> genericDictionaryData = new GenericDictionaryData <DerivedData <RecipientInfoCacheSyncItemId>, RecipientInfoCacheSyncItemId, Int64Data, long>();

            genericDictionaryData.DeserializeData(reader, componentDataPool);
            this.cacheEntryIdToLastUpdateTime = genericDictionaryData.Data;
            DateTimeData dateTimeData = new DateTimeData();

            dateTimeData.DeserializeData(reader, componentDataPool);
            this.lastModifiedTime = dateTimeData.Data;
        }
        // Token: 0x060016D3 RID: 5843 RVA: 0x0008983C File Offset: 0x00087A3C
        public void DeserializeData(BinaryReader reader, ComponentDataPool componentDataPool)
        {
            DateTimeData dateTimeDataInstance = componentDataPool.GetDateTimeDataInstance();

            dateTimeDataInstance.DeserializeData(reader, componentDataPool);
            this.ReceivedDateUtc = dateTimeDataInstance.Data;
            ByteArrayData byteArrayInstance = componentDataPool.GetByteArrayInstance();

            byteArrayInstance.DeserializeData(reader, componentDataPool);
            this.IcsState     = byteArrayInstance.Data;
            this.ChangeNumber = reader.ReadInt32();
        }
 protected override void VerifySyncState(Dictionary <string, DerivedData <ICustomSerializableBuilder> > obj)
 {
     base.VerifySyncState(obj);
     if (base.Version >= 1)
     {
         DateTimeData  dateTimeData  = obj["{9150227d-9140-45d0-b4c2-e987f59cfc46}SyncCalendar.OldestReceivedTime"].Data as DateTimeData;
         ByteArrayData byteArrayData = obj["{9150227d-9140-45d0-b4c2-e987f59cfc46}SyncCalendar.LastInstanceKey"].Data as ByteArrayData;
         BooleanData   booleanData   = obj["{9150227d-9140-45d0-b4c2-e987f59cfc46}SyncCalendar.MoreItemsOnServer"].Data as BooleanData;
         if (dateTimeData == null || byteArrayData == null || booleanData == null)
         {
             throw new CorruptSyncStateException("Empty mandatory key", null);
         }
     }
 }
Пример #9
0
 // Token: 0x0600056E RID: 1390 RVA: 0x0002058C File Offset: 0x0001E78C
 internal void DeserializeData(BinaryReader reader, ComponentDataPool componentDataPool)
 {
     lock (this.instanceLock)
     {
         GenericListData <DateTimeData, ExDateTime> genericListData = new GenericListData <DateTimeData, ExDateTime>();
         genericListData.DeserializeData(reader, componentDataPool);
         this.userAgentTimes = genericListData.Data;
         GenericListData <StringData, string> genericListData2 = new GenericListData <StringData, string>();
         genericListData2.DeserializeData(reader, componentDataPool);
         this.userAgentStrings = genericListData2.Data;
         GenericListData <DateTimeData, ExDateTime> genericListData3 = new GenericListData <DateTimeData, ExDateTime>();
         genericListData3.DeserializeData(reader, componentDataPool);
         this.recentCommandTimes = genericListData3.Data;
         GenericListData <Int32Data, int> genericListData4 = new GenericListData <Int32Data, int>();
         genericListData4.DeserializeData(reader, componentDataPool);
         this.recentCommandHashCodes = genericListData4.Data;
         GenericListData <DateTimeData, ExDateTime> genericListData5 = new GenericListData <DateTimeData, ExDateTime>();
         genericListData5.DeserializeData(reader, componentDataPool);
         this.watsons = genericListData5.Data;
         GenericListData <DateTimeData, ExDateTime> genericListData6 = new GenericListData <DateTimeData, ExDateTime>();
         genericListData6.DeserializeData(reader, componentDataPool);
         this.outOfBudgets = genericListData6.Data;
         GenericListData <DateTimeData, ExDateTime> genericListData7 = new GenericListData <DateTimeData, ExDateTime>();
         genericListData7.DeserializeData(reader, componentDataPool);
         this.syncTimes = genericListData7.Data;
         GenericListData <Int32Data, int> genericListData8 = new GenericListData <Int32Data, int>();
         genericListData8.DeserializeData(reader, componentDataPool);
         this.syncKeys = genericListData8.Data;
         DateTimeData dateTimeDataInstance = componentDataPool.GetDateTimeDataInstance();
         dateTimeDataInstance.DeserializeData(reader, componentDataPool);
         this.blockTime = dateTimeDataInstance.Data;
         DateTimeData dateTimeDataInstance2 = componentDataPool.GetDateTimeDataInstance();
         dateTimeDataInstance2.DeserializeData(reader, componentDataPool);
         this.nextUnblockTime = dateTimeDataInstance2.Data;
         Int32Data int32DataInstance = componentDataPool.GetInt32DataInstance();
         int32DataInstance.DeserializeData(reader, componentDataPool);
         this.autoBlockReason = (DeviceAccessStateReason)int32DataInstance.Data;
         DateTimeData dateTimeDataInstance3 = componentDataPool.GetDateTimeDataInstance();
         dateTimeDataInstance3.DeserializeData(reader, componentDataPool);
         this.timeToUpdateAD = dateTimeDataInstance3.Data;
         if (!this.Validate())
         {
             throw new CorruptSyncStateException(new LocalizedString("DeviceBehavior.DeserializeData"), null);
         }
     }
 }
Пример #10
0
 internal void DeserializeData(BinaryReader reader, ComponentDataPool componentDataPool)
 {
     lock (this.instanceLock)
     {
         DateTimeData dateTimeDataInstance = componentDataPool.GetDateTimeDataInstance();
         dateTimeDataInstance.DeserializeData(reader, componentDataPool);
         this.LastCleanTime = dateTimeDataInstance.Data;
         GenericDictionaryData <StringData, string, MeetingOrganizerEntryData, MeetingOrganizerEntry> genericDictionaryData = new GenericDictionaryData <StringData, string, MeetingOrganizerEntryData, MeetingOrganizerEntry>();
         genericDictionaryData.DeserializeData(reader, componentDataPool);
         this.map     = genericDictionaryData.Data;
         this.IsDirty = false;
         if (this.LastCleanTime - (ExDateTime)TimeProvider.UtcNow > MeetingOrganizerInfo.AllowedClockSkew)
         {
             throw new CorruptSyncStateException(new LocalizedString("DeviceBehavior.DeserializeData"), null);
         }
         this.CleanIfNecessary();
     }
 }
Пример #11
0
        protected override void Seed(DatabaseContext context)
        {
            //Adding Admin User
            var admin = new EvernoteUser
            {
                Name             = "Murat",
                Surname          = "Başeren",
                Email            = "*****@*****.**",
                ActivateGuid     = Guid.NewGuid(),
                IsActive         = true,
                IsAdmin          = true,
                Username         = "******",
                Password         = "******",
                CreatedOn        = DateTime.Now,
                ModifiedOn       = DateTime.Now.AddMinutes(5),
                ModifiedUsername = "******"
            };

            //Adding Standart User
            var standartuser = new EvernoteUser
            {
                Name             = "Kadir",
                Surname          = "Başeren",
                Email            = "*****@*****.**",
                ActivateGuid     = Guid.NewGuid(),
                IsActive         = true,
                IsAdmin          = false,
                Username         = "******",
                Password         = "******",
                CreatedOn        = DateTime.Now,
                ModifiedOn       = DateTime.Now.AddMinutes(65),
                ModifiedUsername = "******"
            };

            context.EvernoteUsers.Add(admin);
            context.EvernoteUsers.Add(standartuser);

            for (var z = 0; z < 8; z++)
            {
                var user = new EvernoteUser
                {
                    Name             = NameData.GetFirstName(),
                    Surname          = NameData.GetSurname(),
                    Email            = NetworkData.GetEmail(),
                    ActivateGuid     = Guid.NewGuid(),
                    IsActive         = true,
                    IsAdmin          = false,
                    Username         = $"user{z}",
                    Password         = "******",
                    CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedUsername = $"user{z}"
                };
                context.EvernoteUsers.Add(user);
            }

            context.SaveChanges();

            //Note:UserList for using...
            var userlist = context.EvernoteUsers.ToList();

            //Note: Adding Fake Categories
            for (var i = 0; i < 10; i++)
            {
                var cat = new Category
                {
                    Title            = PlaceData.GetStreetName(),
                    Description      = PlaceData.GetStreetName(),
                    CreatedOn        = DateTime.Now,
                    ModifiedOn       = DateTime.Now.AddMinutes(5),
                    ModifiedUsername = "******"
                };
                context.Categories.Add(cat);

                //Note:Adding Fake Notes
                for (var k = 0; k < NumberData.GetNumber(5, 9); k++)
                {
                    var note_owner = userlist[NumberData.GetNumber(0, userlist.Count - 1)];
                    var note       = new Note
                    {
                        Title            = TextData.GetAlphabetical(NumberData.GetNumber(5, 25)),
                        Text             = TextData.GetSentences(NumberData.GetNumber(1, 3)),
                        IsDraft          = false,
                        LikeCount        = NumberData.GetNumber(1, 9),
                        Owner            = note_owner,
                        CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                        ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                        ModifiedUsername = note_owner.Username
                    };
                    cat.Notes.Add(note);
                    //Note:Adding Fake Comments

                    for (var j = 0; j < NumberData.GetNumber(3, 5); j++)
                    {
                        var commentowner = userlist[NumberData.GetNumber(0, userlist.Count - 1)];
                        var comment      = new Comment
                        {
                            Text             = TextData.GetSentence(),
                            Owner            = userlist[NumberData.GetNumber(0, userlist.Count - 1)],
                            CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                            ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                            ModifiedUsername = commentowner.Username
                        };
                        note.Comments.Add(comment);
                    }

                    //Note:Adding Fake Likes...


                    for (var j = 0; j < note.LikeCount; j++)
                    {
                        var likes = new Liked
                        {
                            LikedUser = userlist[j]
                        };
                        note.Likes.Add(likes);
                    }
                }
            }

            context.SaveChanges();
        }
Пример #12
0
        public AxisViewModel()
        {
            this.DataPoints = new ObservableCollection <AxisModel>();
            DateTime year = new DateTime(1995, 1, 1);

            DataPoints.Add(new AxisModel()
            {
                Year = year.AddYears(0), Profit = 80
            });
            DataPoints.Add(new AxisModel()
            {
                Year = year.AddYears(1), Profit = 200
            });
            DataPoints.Add(new AxisModel()
            {
                Year = year.AddYears(2), Profit = 400
            });
            DataPoints.Add(new AxisModel()
            {
                Year = year.AddYears(3), Profit = 600
            });
            DataPoints.Add(new AxisModel()
            {
                Year = year.AddYears(4), Profit = 700
            });
            DataPoints.Add(new AxisModel()
            {
                Year = year.AddYears(5), Profit = 1400
            });
            DataPoints.Add(new AxisModel()
            {
                Year = year.AddYears(6), Profit = 2000
            });
            DataPoints.Add(new AxisModel()
            {
                Year = year.AddYears(7), Profit = 4000
            });
            DataPoints.Add(new AxisModel()
            {
                Year = year.AddYears(8), Profit = 6000
            });
            DataPoints.Add(new AxisModel()
            {
                Year = year.AddYears(9), Profit = 8000
            });
            DataPoints.Add(new AxisModel()
            {
                Year = year.AddYears(10), Profit = 11000
            });

            this.CategoryData1 = new ObservableCollection <AxisModel>();
            CategoryData1.Add(new AxisModel()
            {
                XValue = "South Korea", YValue = 39
            });
            CategoryData1.Add(new AxisModel()
            {
                XValue = "India", YValue = 20
            });
            CategoryData1.Add(new AxisModel()
            {
                XValue = "China", YValue = 65
            });

            this.CategoryData2 = new ObservableCollection <AxisModel>();
            CategoryData2.Add(new AxisModel()
            {
                XValue = "France", YValue = 45
            });
            CategoryData2.Add(new AxisModel()
            {
                XValue = "Italy", YValue = 16
            });
            CategoryData2.Add(new AxisModel()
            {
                XValue = "United Kingdom", YValue = 31
            });

            this.DateTimeData = new ObservableCollection <AxisModel>();

            Random   rand  = new Random();
            double   value = 100;
            DateTime date  = new DateTime(2017, 1, 1);

            for (int i = 0; i < 365; i++)
            {
                if (rand.NextDouble() > 0.5)
                {
                    value += rand.NextDouble();
                }
                else
                {
                    value -= rand.NextDouble();
                }

                DateTimeData.Add(new AxisModel {
                    Growth = value, Date = date
                });
                date = date.AddDays(1);
            }

            NumericData = new ObservableCollection <AxisModel>();
            NumericData.Add(new AxisModel()
            {
                Value = 16, Size = 2
            });
            NumericData.Add(new AxisModel()
            {
                Value = 17, Size = 14
            });
            NumericData.Add(new AxisModel()
            {
                Value = 18, Size = 7
            });
            NumericData.Add(new AxisModel()
            {
                Value = 19, Size = 7
            });
            NumericData.Add(new AxisModel()
            {
                Value = 20, Size = 10
            });

            NumericData1 = new ObservableCollection <AxisModel>();
            NumericData1.Add(new AxisModel()
            {
                Value = 16, Size = 7
            });
            NumericData1.Add(new AxisModel()
            {
                Value = 17, Size = 7
            });
            NumericData1.Add(new AxisModel()
            {
                Value = 18, Size = 11
            });
            NumericData1.Add(new AxisModel()
            {
                Value = 19, Size = 8
            });
            NumericData1.Add(new AxisModel()
            {
                Value = 20, Size = 24
            });
        }
Пример #13
0
        protected override void Seed(DatabaseContext context)
        {
            //admin kullanıcı ekleme işlemi.
            EverNoteUser admin = new EverNoteUser()
            {
                Name                = "Aydan",
                SurName             = "Torun",
                Email               = "*****@*****.**",
                ActivateGuid        = Guid.NewGuid(),
                IsActive            = true,
                IsAdmin             = true,
                UserName            = "******",
                Password            = "******",
                CreatedOn           = DateTime.Now,
                ModifiedOn          = DateTime.Now.AddMinutes(5),
                ModifiedUserName    = "******",
                ProfilImageFileName = "user.png"
            };

            //standart kullanıcı ekleme.

            EverNoteUser standartUser = new EverNoteUser()
            {
                Name                = "Maykıl",
                SurName             = "Ceksın",
                Email               = "ceksı[email protected]",
                ActivateGuid        = Guid.NewGuid(),
                IsActive            = true,
                IsAdmin             = false,
                UserName            = "******",
                Password            = "******",
                CreatedOn           = DateTime.Now,
                ModifiedOn          = DateTime.Now.AddMinutes(5),
                ModifiedUserName    = "******",
                ProfilImageFileName = "user.png"
            };

            context.EverNoteUsers.Add(admin);
            context.EverNoteUsers.Add(standartUser);


            //fake kullanıcı ekleme.

            for (int i = 0; i < 8; i++)
            {
                EverNoteUser fakeuser = new EverNoteUser()
                {
                    Name                = NameData.GetFirstName(),
                    SurName             = NameData.GetSurname(),
                    Email               = NetworkData.GetEmail(),
                    ActivateGuid        = Guid.NewGuid(),
                    IsActive            = true,
                    IsAdmin             = false,
                    UserName            = $"user{i}",
                    Password            = "******",
                    CreatedOn           = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                    ModifiedOn          = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                    ModifiedUserName    = $"user{i}",
                    ProfilImageFileName = "user.png"
                };
                context.EverNoteUsers.Add(fakeuser);
            }

            context.SaveChanges();

            //User List For using


            List <EverNoteUser> userList = context.EverNoteUsers.ToList();

            //Adding fake Categories
            for (int i = 0; i < 10; i++)
            {
                Category cat = new Category()
                {
                    Title            = PlaceData.GetStreetName(),
                    Description      = PlaceData.GetAddress(),
                    CreatedOn        = DateTime.Now,
                    ModifiedOn       = DateTime.Now,
                    ModifiedUserName = "******"
                };

                context.Categories.Add(cat);
                //Adding fake Notes

                for (int k = 0; k < NumberData.GetNumber(5, 9); k++)
                {
                    EverNoteUser owner = userList[NumberData.GetNumber(0, userList.Count - 1)];
                    Note         note  = new Note()
                    {
                        Title            = TextData.GetAlphabetical(NumberData.GetNumber(5, 25)),
                        Text             = TextData.GetSentences(NumberData.GetNumber(1, 3)),
                        Category         = cat,
                        IsDraft          = false,
                        LikeCount        = NumberData.GetNumber(1, 9),
                        Owner            = owner,
                        CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                        ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                        ModifiedUserName = owner.UserName
                    };
                    cat.Notes.Add(note);

                    //Adding fake comments

                    for (int j = 0; j < NumberData.GetNumber(3, 5); j++)
                    {
                        EverNoteUser comment_owner = userList[NumberData.GetNumber(0, userList.Count - 1)];
                        Comment      comment       = new Comment()
                        {
                            Text             = TextData.GetSentence(),
                            Owner            = comment_owner,
                            CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                            ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                            ModifiedUserName = comment_owner.UserName,
                            //  Note=note
                        };
                        note.Comments.Add(comment);

                        //Adding sahte beğeniler

                        for (int m = 0; m < note.LikeCount; m++)
                        {
                            Liked liked = new Liked()
                            {
                                LikedUser = userList[m]
                            };
                            note.Likes.Add(liked);
                        }
                    }
                }

                context.SaveChanges();
            }
        }
Пример #14
0
        public void Generate()
        {
            var random = new Random();

            client.PutIndex(new RavenDocumentsByEntityName());
            client.PutIndex(new OrdersByCompany());
            client.PutIndex(new OrdersTotals());
            client.PutIndex(new ProductSales());
            client.PutIndex(new OrdersByEmployeeAndCompany());
            client.PutIndex(new OrdersByEmployeeAndCompanyReduce());

            var nextOrderId    = 1;
            var nextCompanyId  = 1;
            var nextProductId  = 1;
            var nextEmployeeId = 1;

            for (var it = 0; it < numberOfIterations; it++)
            {
                var entities = new List <object>();

                for (var i = 0; i < NumberOfOrdersPerIteration; i++)
                {
                    entities.Add(new Order
                    {
                        Id      = "orders/" + nextOrderId++,
                        Company = "companies/" + random.Next(1, ExpectedNumberOfCompanies - 1),
                        Lines   = CollectionData.GetElement(10, new List <OrderLine>
                        {
                            new OrderLine
                            {
                                Product      = "products/" + random.Next(1, ExpectedNumberOfProducts - 1),
                                Quantity     = random.Next(1, 100),
                                PricePerUnit = random.Next(1000)
                            }
                        }).ToList(),
                        Employee  = "employees/" + random.Next(1, ExpectedNumberOfEmployees - 1),
                        OrderedAt = DateTimeData.GetDatetime(),
                        RequireAt = DateTime.UtcNow.AddDays(7),
                        ShipTo    = new Address
                        {
                            Country    = PlaceData.GetCountry(),
                            City       = PlaceData.GetCity(),
                            PostalCode = PlaceData.GetZipCode(),
                            Line1      = PlaceData.GetStreetName()
                        }
                    });
                }

                for (var i = 0; i < NumberOfCompaniesPerIteration; i++)
                {
                    entities.Add(new Company
                    {
                        Id      = "companies/" + nextCompanyId++,
                        Name    = NameData.GetCompanyName(),
                        Fax     = PhoneNumberData.GetInternationalPhoneNumber(),
                        Address = new Address
                        {
                            Country    = PlaceData.GetCountry(),
                            City       = PlaceData.GetCity(),
                            PostalCode = PlaceData.GetZipCode(),
                            Line1      = PlaceData.GetStreetName()
                        }
                    });
                }

                for (var i = 0; i < NumberOfEmployeesPerIteration; i++)
                {
                    entities.Add(new Employee
                    {
                        Id        = "employees/" + nextEmployeeId++,
                        Birthday  = DateTimeData.GetDatetime(),
                        FirstName = NameData.GetFirstName(),
                        LastName  = NameData.GetSurname(),
                        HomePhone = PhoneNumberData.GetPhoneNumber(),
                        HiredAt   = DateTimeData.GetDatetime(),
                        Address   = new Address
                        {
                            Country    = PlaceData.GetCountry(),
                            City       = PlaceData.GetCity(),
                            PostalCode = PlaceData.GetZipCode(),
                            Line1      = PlaceData.GetStreetName()
                        }
                    });
                }

                for (var i = 0; i < NumberOfProductsPerIteration; i++)
                {
                    entities.Add(new Product
                    {
                        Id           = "products/" + nextProductId++,
                        Category     = TextData.GetAlphabetical(5),
                        Name         = NameData.GetSurname(),
                        Discontinued = BooleanData.GetBoolean(),
                        PricePerUnit = NumberData.GetNumber()
                    });
                }

                client.PutEntities(entities);
            }
        }
Пример #15
0
        public IActionResult ExcelExport()
        {
            // https://steemit.com/utopian-io/@haig/how-to-create-excel-spreadsheets-using-npoi

            var workbook = new HSSFWorkbook();
            var sheet    = workbook.CreateSheet("Sheet 1");

            IFont fontBold = workbook.CreateFont();

            fontBold.Boldweight = (short)FontBoldWeight.Bold;

            var headerCellStyle = workbook.CreateCellStyle();

            headerCellStyle.SetFont(fontBold);

            var   header = sheet.CreateRow(0);
            ICell col1   = header.CreateCell(0); col1.CellStyle = headerCellStyle; col1.SetCellValue("Fullname");
            ICell col2   = header.CreateCell(1); col2.CellStyle = headerCellStyle; col2.SetCellValue("Country");
            ICell col3   = header.CreateCell(2); col3.CellStyle = headerCellStyle; col3.SetCellValue("Email");
            ICell col4   = header.CreateCell(3); col4.CellStyle = headerCellStyle; col4.SetCellValue("Numbers");
            ICell col5   = header.CreateCell(4); col5.CellStyle = headerCellStyle; col5.SetCellValue("Datetime");
            ICell col6   = header.CreateCell(5); col6.CellStyle = headerCellStyle; col6.SetCellValue("Sentence");

            var currencyCellStyle = workbook.CreateCellStyle();

            currencyCellStyle.Alignment  = HorizontalAlignment.Right;
            currencyCellStyle.DataFormat = workbook.CreateDataFormat().GetFormat("₺#.##0,00");;

            int length = 50;

            for (int i = 0; i < length; i++)
            {
                var row = sheet.CreateRow(i + 1);
                row.CreateCell(0).SetCellValue(NameData.GetFullName());
                row.CreateCell(1).SetCellValue(PlaceData.GetCountry());
                row.CreateCell(2).SetCellValue(NetworkData.GetEmail());

                ICell numberCell = row.CreateCell(3);
                numberCell.CellStyle = currencyCellStyle;
                numberCell.SetCellValue(NumberData.GetDouble() * 1000);

                row.CreateCell(4).SetCellValue(DateTimeData.GetDatetime().ToShortDateString());
                row.CreateCell(5).SetCellValue(TextData.GetSentence());
            }

            var   totalRow  = sheet.CreateRow(length + 1);
            ICell totalCell = totalRow.CreateCell(3);

            ICellStyle totalCellStyle = workbook.CreateCellStyle();

            totalCellStyle.CloneStyleFrom(sheet.GetRow(length).GetCell(3).CellStyle);

            totalCell.CellStyle = totalCellStyle;
            totalCell.CellStyle.SetFont(fontBold);
            totalCell.SetCellType(CellType.Formula);
            totalCell.CellFormula = $"SUM(D2:D{length + 1})";   // Headercell den sonrası.

            string root     = _environment.WebRootPath;
            string folder   = Path.Combine(root, "Excels");
            string filename = "f_" + Guid.NewGuid().ToString() + ".xls";
            string file     = Path.Combine(folder, filename);

            if (Directory.Exists(folder) == false)
            {
                Directory.CreateDirectory(folder);
            }

            using (var fileStream = new FileStream(file, FileMode.Create))
            {
                workbook.Write(fileStream);
            }

            return(File("~/Excels/" + filename, "application/vnd.ms-excel"));
        }
Пример #16
0
        public override void HandleSyncStateVersioning(SyncState syncState)
        {
            if (syncState == null)
            {
                throw new ArgumentNullException("syncState");
            }
            if (syncState.BackendVersion == null)
            {
                return;
            }
            bool flag = true;

            if (syncState.BackendVersion < 2 || syncState.BackendVersion > this.Version)
            {
                flag = false;
            }
            else if (syncState.BackendVersion.Value != this.Version)
            {
                string text = null;
                switch (syncState.BackendVersion.Value)
                {
                case 2:
                    syncState["WipeConfirmationAddresses"] = null;
                    break;

                case 3:
                    break;

                case 4:
                    goto IL_14F;

                case 5:
                case 6:
                case 7:
                case 8:
                case 9:
                case 10:
                case 11:
                case 12:
                case 13:
                case 14:
                case 15:
                case 16:
                case 17:
                case 18:
                case 19:
                    goto IL_3B6;

                case 20:
                    goto IL_16C;

                case 21:
                    goto IL_184;

                case 22:
                    goto IL_1A6;

                case 23:
                    goto IL_1D2;

                case 24:
                    goto IL_1EF;

                case 25:
                    goto IL_1FA;

                case 26:
                    goto IL_212;

                case 27:
                    goto IL_259;

                case 28:
                    goto IL_2D8;

                case 29:
                    goto IL_2E4;

                case 30:
                    goto IL_2EF;

                case 31:
                    goto IL_2FB;

                case 32:
                    goto IL_306;

                case 33:
                    goto IL_312;

                case 34:
                    goto IL_31E;

                case 35:
                    goto IL_32A;

                case 36:
                    goto IL_358;

                case 37:
                    goto IL_39E;

                default:
                    goto IL_3B6;
                }
                syncState[CustomStateDatumType.UserAgent] = null;
IL_14F:
                syncState["LastAdUpdateTime"] = null;
                syncState["DeviceHealth"]     = new Int32Data(0);
IL_16C:
                text = syncState.GetData <StringData, string>("LastPolicyXML", null);
                syncState.Remove("LastPolicyXML");
IL_184:
                syncState["ProvisionSupported"] = new BooleanData(syncState.GetData <UInt32Data, uint>("PolicyKeyOnDevice", 0U) != 0U);
IL_1A6:
                syncState["LastPolicyXMLHash"] = ((text == null) ? null : new NullableData <Int32Data, int>(new int?(PolicyData.GetPolicyHashCode(text + true))));
IL_1D2:
                syncState["DeviceEnableOutboundSMS"] = new BooleanData(false);
                syncState["DeviceMobileOperator"]    = null;
IL_1EF:
                syncState.Remove("LastAdUpdateTime");
IL_1FA:
                syncState["ClientAlternateMailboxInformationVersion"] = null;
                syncState["DeviceUMRegisteredPhoneNumber"]            = null;
IL_212:
                syncState["HaveSentBoostrapMailForWM61"] = new BooleanData(false);
                if (syncState.BackendVersion.Value < 20)
                {
                    syncState["SSUpgradeDateTime"] = new DateTimeData(ExDateTime.UtcNow);
                }
                else
                {
                    syncState["SSUpgradeDateTime"] = null;
                }
IL_259:
                syncState.Remove("DeviceHealth");
                syncState["DeviceAccessState"]             = new Int32Data(0);
                syncState["DeviceAccessStateReason"]       = new Int32Data(0);
                syncState["DevicePolicyApplied"]           = null;
                syncState["DevicePolicyApplicationStatus"] = new Int32Data(0);
                syncState["LastDeviceWipeRequestor"]       = null;
                syncState["DeviceActiveSyncVersion"]       = null;
                syncState["ADDeviceInfoHash"]          = null;
                syncState["DeviceInformationReceived"] = new BooleanData(false);
IL_2D8:
                syncState["ADCreationTime"] = null;
IL_2E4:
                syncState.Remove("DeviceUMRegisteredPhoneNumber");
IL_2EF:
                syncState["NextTimeToClearMailboxLogs"] = null;
IL_2FB:
                syncState.Remove("ClientAlternateMailboxInformationVersion");
IL_306:
                syncState["DeviceADObjectId"] = null;
IL_312:
                syncState["BootstrapMailForWM61TriggeredTime"] = null;
IL_31E:
                syncState["UserADObjectId"] = null;
IL_32A:
                syncState["ABQMailId"]    = null;
                syncState["ABQMailState"] = new Int32Data(0);
                syncState["DeviceInformationPromoted"] = new BooleanData(false);
IL_358:
                syncState["DevicePhoneNumberForSms"] = ((syncState["DevicePhoneNumber"] != null) ? new StringData(((StringData)syncState["DevicePhoneNumber"]).Data) : null);
                syncState["SmsSearchFolderCreated"]  = new BooleanData(false);
IL_39E:
                syncState["DeviceBehavior"] = new DeviceBehaviorData(new DeviceBehavior(true));
                goto IL_3B8;
IL_3B6:
                flag = false;
            }
IL_3B8:
            if (!flag)
            {
                syncState.HandleCorruptSyncState();
            }
        }
Пример #17
0
 protected bool Equals(Class1 other)
 {
     return(TextData == other.TextData && DateTimeData.Equals(other.DateTimeData) &&
            DoubleData.Equals(other.DoubleData) && Equals(Class2, other.Class2) && Equals(Class3, other.Class3));
 }
Пример #18
0
        /**
         * @param data The AnswerDataObject to be serialized
         * @return A String which contains a date in xsd:date
         * formatting
         */
        public Object serializeAnswerData(DateTimeData data)
        {
            DateTime dt = (DateTime)data.Value;

            return(DateUtils.formatDateTime(ref dt, DateUtils.FORMAT_ISO8601));
        }
Пример #19
0
        protected override void Seed(ZeroDbContext context)
        {
            var admin = new ApplicationUser()
            {
                Id        = 1,
                FirstName = "Ekin",
                LastName  = "Memiş",
                Email     = "*****@*****.**",
                Password  = "******",
                Active    = true,
                Deleted   = false,
            };

            context.ApplicationUser.AddOrUpdate(admin);

            Random rnd = new Random();

            for (int i = 0; i < 100; i++)
            {
                Customer customer = new Customer
                {
                    Id                    = i,
                    Active                = true,
                    DateOfBirth           = DateTimeData.GetDatetime(),
                    Deleted               = false,
                    Email                 = NetworkData.GetEmail(),
                    FirstName             = NameData.GetFirstName(),
                    LastName              = NameData.GetSurname(),
                    PalceOfBirth          = FakeData.PlaceData.GetAddress(),
                    PhoneNumber           = PhoneNumberData.GetPhoneNumber(),
                    TurkishIdentityNumber = NumberData.GetDouble().ToString(),
                };
                context.Customer.AddOrUpdate(customer);

                Employee employee = new Employee
                {
                    Id                    = i,
                    Active                = true,
                    DateOfBirth           = DateTimeData.GetDatetime(),
                    Deleted               = false,
                    Email                 = NetworkData.GetEmail(),
                    FirstName             = NameData.GetFirstName(),
                    LastName              = NameData.GetSurname(),
                    PalceOfBirth          = FakeData.PlaceData.GetAddress(),
                    PhoneNumber           = PhoneNumberData.GetPhoneNumber(),
                    TurkishIdentityNumber = NumberData.GetDouble().ToString(),
                    Sallary               = NumberData.GetNumber(),
                    Title                 = NameData.GetCompanyName()
                };
                context.Employee.AddOrUpdate(employee);

                AppointmentType appointmentType = new AppointmentType
                {
                    Id = i,
                    DefaultSeanceQuantity = NumberData.GetNumber(1, 10),
                    Name    = TextData.GetAlphabetical(5),
                    Deleted = false,
                };
                context.AppointmentType.AddOrUpdate(appointmentType);

                Appointment appointment = new Appointment
                {
                    Id                  = i,
                    Deleted             = false,
                    StartDate           = DateTimeData.GetDatetime(),
                    EndDate             = DateTimeData.GetDatetime(),
                    Price               = NumberData.GetNumber(),
                    PriceIncludedTax    = NumberData.GetNumber(),
                    Name                = TextData.GetAlphabetical(5),
                    AppointmentStatusId = 0,
                    AppointmentTypeId   = rnd.Next(100),
                };
                context.Appointment.AddOrUpdate(appointment);
            }
        }
Пример #20
0
        protected override void Seed(LoginYap4.DataAccessLayer.DatabaseContext context)
        {
            //TRIGGER: şarkı silindiğinde log tablosuna silinme bilgilerini tutan
            context.Database.ExecuteSqlCommand(@"
            create trigger TG_SongDelete on Song after delete 
            as 
            begin
             declare @song_name nvarchar(50)
             declare @viewed_number int
             declare @olusturma_tarih Date
             declare @aciklama nvarchar(50)
             set @aciklama = 'Bir şarkı silindi';
             select @song_name = Name				from deleted 
             select @viewed_number = ViewedNumber	from deleted 
             select @olusturma_tarih = CreatedOn	from deleted 
             insert into dbo.Logs values (@song_name,@olusturma_tarih,@viewed_number,@aciklama)
            end
            ");
            //FONKSYON:sitedeki toplam şarkı sayısı
            context.Database.ExecuteSqlCommand(@"
            create function SongCount()
            returns int
            as
            begin

            declare @counter int;

            select @counter = Count(Id) from Song
            return @counter;
            end
            
            ");
            //PROSEDUR: idsi verilen kullanıcının kullanı bilgilerini verir
            context.Database.ExecuteSqlCommand(@"
            create procedure GetUsernameById
            @id int
            AS 
            Begin
 
            select Name, Surname, Username from SiteUser where Id = @id
            END  
            ");



            string[] chords = new string[] { "A", "B", "C", "D", "E", "F", "G", "Am", "Bm", "Cm", "Dm", "Em", "Fm", "Gm" };

            for (int h = 0; h < 14; h++)
            {
                Chord chord = new Chord();
                chord.Name = chords[h];
                context.Chords.Add(chord);
            }
            context.SaveChanges();

            // Adding admin user..
            SiteUser admin = new SiteUser()
            {
                Name                 = "Engin",
                Surname              = "Karataş",
                Email                = "*****@*****.**",
                ActivateGuid         = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = true,
                Username             = "******",
                ProfileImageFilename = "user_boy.png",
                Password             = "******",
                CreatedOn            = DateTime.Now,
                ModifiedOn           = DateTime.Now.AddMinutes(5),
                ModifiedUsername     = "******"
            };

            // Adding standart user..
            SiteUser standartUser = new SiteUser()
            {
                Name                 = "Engin",
                Surname              = "Karataş",
                Email                = "*****@*****.**",
                ActivateGuid         = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = false,
                Username             = "******",
                Password             = "******",
                ProfileImageFilename = "user_boy.png",
                CreatedOn            = DateTime.Now.AddHours(1),
                ModifiedOn           = DateTime.Now.AddMinutes(65),
                ModifiedUsername     = "******"
            };

            context.SiteUsers.Add(admin);
            context.SiteUsers.Add(standartUser);

            for (int i = 0; i < 8; i++)
            {
                SiteUser user = new SiteUser()
                {
                    Name                 = FakeData.NameData.GetFirstName(),
                    Surname              = FakeData.NameData.GetSurname(),
                    Email                = FakeData.NetworkData.GetEmail(),
                    ActivateGuid         = Guid.NewGuid(),
                    IsActive             = true,
                    ProfileImageFilename = "user_boy.png",
                    IsAdmin              = false,
                    Username             = $"user{i}",
                    Password             = "******",
                    CreatedOn            = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedOn           = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedUsername     = $"user{i}"
                };
                context.SiteUsers.Add(user);
            }
            context.SaveChanges();


            for (int i = 0; i < 10; i++)
            {
                SiteUser user = new SiteUser
                {
                    Name                 = FakeData.NameData.GetFirstName(),
                    Surname              = FakeData.NameData.GetSurname(),
                    Email                = FakeData.NetworkData.GetEmail(),
                    ActivateGuid         = Guid.NewGuid(),
                    IsActive             = true,
                    ProfileImageFilename = "user_boy.png",
                    IsAdmin              = false,
                    isArtist             = true,
                    Username             = $"user{i}",
                    Password             = "******",
                    CreatedOn            = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedOn           = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedUsername     = $"user{i}"
                };
                context.SiteUsers.Add(user);
            }


            List <SiteUser> userlist = context.SiteUsers.ToList();

            // Adding fake categories..
            for (int i = 0; i < 17; i++)
            {
                Category cat = new Category()
                {
                    Title            = FakeData.TextData.GetAlphabetical(FakeData.NumberData.GetNumber(5, 12)) + " " + FakeData.TextData.GetAlphabetical(FakeData.NumberData.GetNumber(3, 8)),
                    Description      = FakeData.PlaceData.GetAddress(),
                    CreatedOn        = DateTime.Now,
                    ModifiedOn       = DateTime.Now,
                    ModifiedUsername = "******"
                };

                context.Categories.Add(cat);

                // Adding fake Songs..
                for (int k = 0; k < FakeData.NumberData.GetNumber(5, 9); k++)
                {
                    SiteUser owner = userlist[FakeData.NumberData.GetNumber(0, userlist.Count - 1)];

                    Song song = new Song()
                    {
                        Name                        = FakeData.PlaceData.GetStreetName(),
                        ViewedNumber                = FakeData.NumberData.GetNumber(22, 328),
                        RateNumber                  = FakeData.NumberData.GetNumber(0, 5),
                        Writer                      = "engin",
                        CoveredArtist               = "owner",
                        Picture                     = "song.png",
                        Artist                      = "owner",
                        Text                        = FakeData.TextData.GetSentences(FakeData.NumberData.GetNumber(25, 50)),
                        IsDraft                     = false,
                        TextSalt                    = FakeData.TextData.GetSentences(FakeData.NumberData.GetNumber(1, 2)),
                        LikeCount                   = FakeData.NumberData.GetNumber(1, 9),
                        Owner                       = owner,
                        CreatedOn                   = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                        ModifiedOn                  = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                        ModifiedUsername            = owner.Username,
                        PublishedDate               = DateTimeData.GetDatetime(),
                        PublishedCoverDateOnYouTube = DateTimeData.GetDatetime(),
                    };
                    cat.Songs.Add(song);



                    // Adding fake comments
                    for (int j = 0; j < FakeData.NumberData.GetNumber(3, 5); j++)
                    {
                        SiteUser comment_owner = userlist[FakeData.NumberData.GetNumber(0, userlist.Count - 1)];

                        Comment comment = new Comment()
                        {
                            Text             = FakeData.TextData.GetSentence(),
                            Owner            = comment_owner,
                            CreatedOn        = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                            ModifiedOn       = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                            ModifiedUsername = comment_owner.Username
                        };

                        song.Comments.Add(comment);
                    }

                    // Adding fake likes..

                    for (int m = 0; m < song.LikeCount; m++)
                    {
                        Liked liked = new Liked()
                        {
                            LikedUser = userlist[m]
                        };

                        song.Likes.Add(liked);
                    }
                }
            }

            context.SaveChanges();
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.
        }
Пример #21
0
        protected override void Seed(DatabaseContext context)
        {
            EverNoteUser admin = new EverNoteUser()
            {
                Name                 = "Ayan",
                Surname              = "Ünal",
                Email                = "*****@*****.**",
                ActiveGuid           = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = true,
                UserName             = "******",
                Password             = "******",
                CreatedOn            = DateTime.Now,
                ModifiedOn           = DateTime.Now.AddMinutes(5),
                ModifiedUserName     = "******",
                ProfileImageFileName = "userimg.jfif"
            };
            EverNoteUser standartuser = new EverNoteUser()
            {
                Name                 = "Can",
                Surname              = "Ünal",
                Email                = "*****@*****.**",
                ActiveGuid           = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = true,
                UserName             = "******",
                Password             = "******",
                CreatedOn            = DateTime.Now,
                ModifiedOn           = DateTime.Now.AddMinutes(5),
                ModifiedUserName     = "******",
                ProfileImageFileName = "userimg.jfif"
            };

            context.EverNoteUsers.Add(admin);
            context.EverNoteUsers.Add(standartuser);

            //Adding fake user
            for (int i = 0; i < 8; i++)
            {
                EverNoteUser fakeuser = new EverNoteUser()
                {
                    Name                 = NameData.GetFirstName(),
                    Surname              = NameData.GetSurname(),
                    Email                = NetworkData.GetEmail(),
                    ActiveGuid           = Guid.NewGuid(),
                    IsActive             = true,
                    IsAdmin              = false,
                    UserName             = $"user{i}",
                    Password             = "******",
                    CreatedOn            = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                    ModifiedOn           = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                    ModifiedUserName     = $"user{i}",
                    ProfileImageFileName = "userimg.jfif"
                };
                context.EverNoteUsers.Add(fakeuser);
            }

            context.SaveChanges();

            //user lidt for using
            List <EverNoteUser> userlist = context.EverNoteUsers.ToList();

            //adding fake categories
            for (int i = 0; i < 10; i++)
            {
                Category cat = new Category()
                {
                    Title            = PlaceData.GetStreetName(),
                    Description      = PlaceData.GetAddress(),
                    CreatedOn        = DateTime.Now,
                    ModifiedOn       = DateTime.Now,
                    ModifiedUserName = "******"
                };
                context.Categories.Add(cat);
                //adding fake notes
                for (int k = 0; k < NumberData.GetNumber(5, 9); k++)
                {
                    EverNoteUser owner = userlist[NumberData.GetNumber(0, userlist.Count - 1)];
                    Note         note  = new Note()
                    {
                        Title            = TextData.GetAlphabetical(NumberData.GetNumber(5, 25)),
                        Text             = TextData.GetSentences(NumberData.GetNumber(1, 3)),
                        Category         = cat,
                        IsDraft          = false,
                        LikeCount        = NumberData.GetNumber(1, 9),
                        Owner            = owner,
                        CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                        ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                        ModifiedUserName = owner.UserName
                    };
                    cat.Notes.Add(note);
                    //adding fake comment
                    for (int j = 0; j < NumberData.GetNumber(3, 5); j++)
                    {
                        EverNoteUser comment_owner = userlist[NumberData.GetNumber(0, userlist.Count - 1)];
                        Comment      comment       = new Comment()
                        {
                            Text             = TextData.GetSentence(),
                            Owner            = comment_owner,
                            CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                            ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                            ModifiedUserName = comment_owner.UserName
                                               //Note=note
                        };
                        note.Comments.Add(comment);

                        //adding fake likes
                        for (int m = 0; m < note.LikeCount; m++)
                        {
                            Liked liked = new Liked()
                            {
                                LikedUser = userlist[m]
                            };
                            note.Likes.Add(liked);
                        }
                    }
                }
                context.SaveChanges();
            }
        }
Пример #22
0
        // Adding Admin User
        protected override void Seed(DatabaseContext context) // db den context türettik
        {
            EverNoteUser admin = new EverNoteUser()
            {
                Name                = "Melike",
                Surname             = "Arıkan",
                Email               = "*****@*****.**",
                ActivateGuid        = Guid.NewGuid(),
                IsActive            = true,
                IsAdmin             = true,
                UserName            = "******",
                Password            = "******",
                CreatedOn           = DateTime.Now,
                ModifiedOn          = DateTime.Now.AddMinutes(5),
                ModifiedUserName    = "******",
                ProfilImageFileName = "userImage.jfif"
            };

            // Adding Standart User

            EverNoteUser standartUser = new EverNoteUser()
            {
                Name                = "Muhammet",
                Surname             = "Tiryaki",
                Email               = "*****@*****.**",
                ActivateGuid        = Guid.NewGuid(),
                IsActive            = true,
                IsAdmin             = true,
                UserName            = "******",
                Password            = "******",
                CreatedOn           = DateTime.Now,
                ModifiedOn          = DateTime.Now.AddMinutes(5),
                ModifiedUserName    = "******",
                ProfilImageFileName = "userImage.jfif"
            };

            context.EverNoteUsers.Add(admin);
            context.EverNoteUsers.Add(standartUser);



            // Using Fake User

            for (int i = 0; i < 8; i++)
            {
                EverNoteUser fake = new EverNoteUser()
                {
                    Name                = NameData.GetFirstName(),
                    Surname             = NameData.GetSurname(),
                    Email               = NetworkData.GetEmail(),
                    ActivateGuid        = Guid.NewGuid(),
                    IsActive            = true,
                    IsAdmin             = true,
                    UserName            = $"user{i}",
                    Password            = "******",
                    CreatedOn           = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                    ModifiedOn          = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                    ModifiedUserName    = $"user{i}",
                    ProfilImageFileName = "userImage.jfif"
                };

                context.EverNoteUsers.Add(fake);
            }


            context.SaveChanges();

            // User List For Using

            List <EverNoteUser> userList = context.EverNoteUsers.ToList();

            // Adding Fake Categories

            for (int i = 0; i < 10; i++)
            {
                Category cat = new Category()
                {
                    Title            = PlaceData.GetStreetName(),
                    Description      = PlaceData.GetAddress(),
                    CreatedOn        = DateTime.Now,
                    ModifiedOn       = DateTime.Now,
                    ModifiedUserName = "******"
                };

                context.Categories.Add(cat);

                // Adding Fake Notes

                for (int k = 0; k < NumberData.GetNumber(5, 9); k++)
                {
                    EverNoteUser owner = userList[NumberData.GetNumber(0, userList.Count - 1)];
                    Note         note  = new Note()
                    {
                        Title            = TextData.GetAlphabetical(NumberData.GetNumber(5, 25)),
                        Text             = TextData.GetSentences(NumberData.GetNumber(1, 3)),
                        Category         = cat,
                        IsDraft          = false,
                        LikeCount        = NumberData.GetNumber(1, 9),
                        Owner            = owner,
                        CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                        ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                        ModifiedUserName = owner.UserName
                    };
                    cat.Notes.Add(note);

                    //Adding Fake Comment

                    for (int j = 0; j < NumberData.GetNumber(3, 5); j++)
                    {
                        EverNoteUser comment_owner = userList[NumberData.GetNumber(0, userList.Count - 1)];
                        Comment      comment       = new Comment()
                        {
                            Text             = TextData.GetSentence(),
                            Owner            = comment_owner,
                            CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                            ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                            ModifiedUserName = comment_owner.UserName,
                            Note             = note
                        };
                        note.Comments.Add(comment);

                        // Adding Fake Likes
                        for (int m = 0; m < note.LikeCount; m++)
                        {
                            Liked liked = new Liked()
                            {
                                LikedUser = userList[m]
                            };
                            note.Likes.Add(liked);
                        }
                    }
                }
                context.SaveChanges();
            }
        }