예제 #1
0
        // GET: Subscription

        public ActionResult ReactivationInstructions()
        {
            tenant tenant = (tenant)TempData["tenant"];

            ViewBag.Message = (string)TempData["Message"];
            bool hasPaymentInfo = false;

            if (tenant == null)
            {
                //TempData["Message"] = "Your user is not a customer";
                return(RedirectToAction("Login", "Home", new { area = "" }));
            }
            ChargifyConnect chargify     = ChargifyTools.Chargify;
            ISubscription   subscription = ChargifyTools.getSubscription(tenant.billingRefNumber);

            if (subscription == null)
            {
                TempData["Message"] = "Your user is not a customer";
                return(RedirectToAction("Login", "Home", new { area = "" }));
            }


            if (subscription.PaymentProfile != null)
            {
                hasPaymentInfo = true;
            }
            ViewBag.hasPaymentInfo = hasPaymentInfo;
            ViewBag.tenantId       = tenant.tenantId;
            ViewBag.paymentUrl     = chargify.GetPrettySubscriptionUpdateURL("", "", subscription.SubscriptionID);
            return(View());
        }
예제 #2
0
 /// <summary>
 /// adding the new tenant
 /// </summary>
 /// <param name="tenant"></param>
 public void AddNewTenant(tenant tenant, int propertyId)
 {
     tenant.tenant_property_id = propertyId;
     contex.tenants.Add(tenant);
     contex.SaveChanges();
     MainWindow.TenantDataGrid.ItemsSource = contex.tenants.ToList();
 }
예제 #3
0
        /// <summary>
        /// Deleting the tenant
        /// </summary>
        /// <param name="tenant"></param>
        public void DeleteTenant(tenant tenant)
        {
            var delTenant = (from t in contex.tenants
                             where t.tenant_id == tenant.tenant_id
                             select t).Single();

            contex.tenants.Remove(delTenant);
            contex.SaveChanges();
            MainWindow.TenantDataGrid.ItemsSource = contex.tenants.ToList();
        }
예제 #4
0
 public void CopyTo(ref tenant tenant)
 {
     foreach (var propertyInfo in tenant.GetType().GetProperties())
     {
         if (!propertyInfo.Name.Contains("Id") && (propertyInfo.PropertyType.IsValueType || propertyInfo.PropertyType.Name == "String"))
         {
             propertyInfo.SetValue(tenant, propertyInfo.GetValue(this));
         }
     }
 }
예제 #5
0
        public ActionResult Reactivation(int tenantId)
        {
            if (tenantId <= 0)
            {
                return(RedirectToAction("Login", "Home", new { area = "" }));
            }
            tenant tenant = db.tenant.Find(tenantId);

            if (tenant == null)
            {
                return(RedirectToAction("Login", "Home", new { area = "" }));
            }
            ChargifyConnect chargify            = ChargifyTools.Chargify;
            ISubscription   currentSubscription = ChargifyTools.getSubscription(tenant.billingRefNumber);

            if (currentSubscription == null)
            {
                return(RedirectToAction("Login", "Home", new { area = "" }));
            }
            if (currentSubscription.PaymentProfile != null)
            {
                try
                {
                    ISubscription reactivatedSubscription = chargify.ReactivateSubscription(currentSubscription.SubscriptionID);
                    if (reactivatedSubscription.State == SubscriptionState.Active)
                    {
                        TempData["Message"] = "Your subscription has been successfully reactivated.\n please login again";
                        return(RedirectToAction("Login", "Home", new { area = "" }));
                    }
                    else
                    {
                        TempData["Message"] = "Your subscription couldn't be activated.\n Follow the instructions and try again";
                        TempData["tenant"]  = tenant;
                        //return RedirectToAction("Login", "Home", new { area = "" });
                        return(RedirectToAction("ReactivationInstructions"));
                    }
                }
                catch (Exception)
                {
                    TempData["Message"] = "Your subscription couldn't be activated.\n Follow the instructions and try again";
                    TempData["tenant"]  = tenant;
                    //return RedirectToAction("Login", "Home", new { area = "" });
                    return(RedirectToAction("ReactivationInstructions"));
                }
            }
            else
            {
                TempData["Message"] = "You haven't set your payment information.\n Follow the instructions and try again";
                TempData["tenant"]  = tenant;
                return(RedirectToAction("ReactivationInstructions", tenant));
            }

            return(View());
        }
예제 #6
0
 public NewTenantModel(tenant tenant)
 {
     foreach (var propertyInfo in tenant.GetType().GetProperties())
     {
         if (propertyInfo.PropertyType.IsValueType || propertyInfo.PropertyType.Name == "String")
         {
             propertyInfo.SetValue(this, propertyInfo.GetValue(tenant));
         }
     }
     Email    = tenant.user.Email;
     Password = tenant.user.Password;
     Deleted  = tenant.user.Deleted;
 }
예제 #7
0
        static void Main(string[] args)
        {
            const string tTargetName       = "Tenant 2 Test";
            string       tTargetIdentifier = Util.MakeIdentifierRootIdentifier(typeof(tenant).Name, Util.TrimWhitespace(tTargetName));

            const string mTargetName       = "Model 2 Test";
            string       mTargetIdentifier = Util.MakeIdentifierFromParentIdentifier(
                Util.MakeIdentifierRootIdentifier(typeof(tenant).Name, tTargetName),
                typeof(model).Name, Util.TrimWhitespace(mTargetName));

            tenant tTarget = null;
            model  mTarget = null;

            using (var ctxTarget = new ModelMateEFModel9Context())
            {
                ctxTarget.Database.Log = Console.Write;

                tTarget = ModelFinder.FindTenant(ctxTarget, tTargetIdentifier, "");
                ModelDump.DisplayDBPropertyValues("tTarget", ctxTarget.Entry(tTarget).CurrentValues, null);

                folders fs0 = tTarget.folders.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("fs0", ctxTarget.Entry(fs0).CurrentValues, null);
                folder f0 = fs0.folder.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("f0", ctxTarget.Entry(f0).CurrentValues, null);

                mTarget = ModelFinder.FindModel(ctxTarget, tTarget, mTargetIdentifier, null);
                ModelDump.DisplayDBPropertyValues("mTarget", ctxTarget.Entry(mTarget).CurrentValues, null);

                string  modelSchemaFile = @"..\..\..\PSN.ModelMate.Schema\Schema\ModelMateModel9.xsd";
                DataSet dsModel         = new DataSet();
                dsModel.ReadXmlSchema(modelSchemaFile);
                //DataSet ds3 = dsModel.Copy();
                //var mmpModel = new ModelMateProcessor();
                var mmpModel = new ModelProcessor(ModelProcessor.ConvertModel2AMEFFDataSet);
                mmpModel.ProcessModel(dsModel, (DbContext)ctxTarget, new Collection <model> {
                    mTarget
                });
                //dsModel.WriteXml("modelds.xml", XmlWriteMode.IgnoreSchema);
                string filename = "model4archi.xml";
                mmpModel.SaveAMEFFDataSetAsXML(dsModel, filename);

                Console.WriteLine("Press Enter to exit...");
                Console.ReadLine();
            }
        }
예제 #8
0
        static void Main(string[] args)
        {
            int id = (Int32)DateTime.Now.Ticks;
            Console.WriteLine("id: " + id.ToString());

            var tenant1 = new tenant();
            tenant1.tenant_Id = id++;
            var tname = new name();
            tname.name_Id = id++;
            tname.lang = "en-us";
            tname.name_text = "tenant " + DateTime.Now.ToString();
            tenant1.name.Add(tname);

            var folders = new folders();
            folders.folders_Id = id++;
            var fname = new name();
            fname.lang = "en-us";
            fname.name_Id = id++;
            fname.name_text = "folders " + DateTime.Now.ToString();

            tenant1.folders.Add(folders);

            using (var ctx = new PSN.ModelMate.EDM.ModelMateEFModel9Context())
            {
                ctx.Database.Log = Console.Write;
                ctx.tenant.Add(tenant1);
                ctx.SaveChanges();
            }

            using (var ctx = new PSN.ModelMate.EDM.ModelMateEFModel9Context())
            {
                ctx.Database.Log = Console.Write;
                var tenant2 = ctx.tenant.Find(new object[] { tenant1.tenant_Id });
                Console.WriteLine("tenant.name.count: " + tenant2.name.Count);
                Console.WriteLine("tenant.folders.count: " + tenant2.folders.Count);
                ctx.SaveChanges();
            }

            Console.WriteLine("Press enter to continue...");
            Console.ReadLine();

        }
예제 #9
0
        public void AddusersBilling(int count)
        {
            Sqrely_Identity identity = clsCommon.getIdentity();

            if (count > 0)
            {
                try
                {
                    ChargifyConnect Chargify = clsCommon.Chargify;
                    // Load the customer information for the current user
                    //ICustomer customer = Chargify.Find<Customer>(clsCommon.getCurrentUserBillingRefNumber());
                    // Alternate syntax
                    // Dim customer As ICustomer = Chargify.LoadCustomer(clsCommon.getCurrentUserBillingRefNumber())
                    tenant        currentenant        = db.tenant.Find(identity.tenatId);
                    ISubscription currentSubscription = ChargifyTools.getSubscription(currentenant.billingRefNumber);
                    if (currentSubscription != null)
                    {
                        int componentID = clsCommon.getComponentId(currentSubscription.Product.Handle);
                        if (componentID > 0)
                        {
                            //Update the amount allocated
                            //Dim info As IComponentAttributes = Chargify.UpdateComponentAllocationForSubscription(currentSubscription.SubscriptionID, componentID, (CInt(noUsersTb.Text) - 1))
                            //Dim info As IComponentAttributes = Chargify.UpdateComponentAllocationForSubscription(currentSubscription.SubscriptionID, componentID, newQuantity)
                            //Chargify.CreateComponentAllocation(currentSubscription.SubscriptionID, componentID, count, "New Users", ComponentUpgradeProrationScheme.No_Prorate, ComponentDowngradeProrationScheme.No_Prorate);
                            if (currentSubscription.State == SubscriptionState.Trialing)
                            {
                                Chargify.CreateComponentAllocation(currentSubscription.SubscriptionID, componentID, count, "New Users", ComponentUpgradeProrationScheme.No_Prorate, ComponentDowngradeProrationScheme.No_Prorate);
                            }
                            else
                            {
                                Chargify.CreateComponentAllocation(currentSubscription.SubscriptionID, componentID, count, "New Users", ComponentUpgradeProrationScheme.Prorate_Attempt_Capture, ComponentDowngradeProrationScheme.Prorate);
                            }
                        }
                        //Dim sqltext As String = "UPDATE tenant SET modifyDateTime=getdate(), " &
                        //" allocatedUsers = @allocatedUsers " &
                        //" WHERE billingRefNumber = @billingRefNumber"
                        //ApplicationBlocks.SqlHelper.ExecuteNonQuery(clsCommon.connString,
                        //                                        System.Data.CommandType.Text, sqltext,
                        //                                    New System.Data.SqlClient.SqlParameter("@allocatedUsers", noUsersTb.Text),
                        //                                    New System.Data.SqlClient.SqlParameter("@billingRefNumber", currentSubscription.Customer.SystemID))
                        //tenant tenant = default(tenant);
                        //tenant = (from t in db.tenantwhere t.billingRefNumber.Equals(currentSubscription.Customer.SystemID)).FirstOrDefault();

                        currentenant.allocatedUsers = count + 1;
                        //Dim identity As SQRely_Admin.SqrelySecurity.Sqrely_Identity
                        //identity = HttpContext.Current.User.Identity
                        currentenant.updatedById     = identity.Id;
                        currentenant.modifyDateTime  = DateTime.Now;
                        db.Entry(currentenant).State = EntityState.Modified;
                        db.SaveChanges();
                        //LoadSubscriptionInfo();
                        //usageResultLtr.Text = string.Format("Current Allocated users ({0}).", noUsersTb.Text);
                        //If newAddedUsers > 0 Then
                        //    ' Charge Existing Users on new account
                        //    Dim amount As Decimal = newAddedUsers * currentSubscription.ProductPrice
                        //    Chargify.CreateCharge(currentSubscription.SubscriptionID, amount, String.Format("New Users Added: {0}", newAddedUsers.ToString()), True)
                        //End If

                        //' Get the amount allocated
                        //Dim newInfo As IComponentAttributes = Chargify.GetComponentInfoForSubscription(currentSubscription.SubscriptionID, componentID)

                        //If newInfo IsNot Nothing Then
                        //    ' Charged OK
                        //    Me.usageResultLtr.Text = String.Format("Current additional users ({0}).", noUsersTb.Text)
                        //    ScriptManager.RegisterStartupScript(Me.Page, GetType(Page), "highlight", "HighlightResult();", True)
                        //Else
                        //    ' Not OK
                        //    Me.usageResultLtr.Text = String.Format("Error. ({0})", DateTime.Now.ToString())
                        //    ScriptManager.RegisterStartupScript(Me.Page, GetType(Page), "highlight", "HighlightResult();", True)
                        //End If
                    }
                }
                catch (Exception ex)
                {
                    //ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "error", "alert('" + ex.Message + "');", true);
                }
            }
        }
예제 #10
0
        public JsonResult GetInfoClient()
        {
            var             result              = Json("", JsonRequestBehavior.AllowGet);
            int             currentuser         = clsCommon.getIdentity().Id;
            int             tenantid            = clsCommon.getIdentity().tenatId;
            tenant          ctenant             = (from t in db.tenant where t.tenantId == tenantid select t).FirstOrDefault();
            ChargifyConnect chargify            = clsCommon.Chargify;
            int             usercount           = 1;
            bool            validpaid           = false;
            ISubscription   currentSubscription = ChargifyTools.getSubscription(ctenant.billingRefNumber);

            if (currentSubscription != null)
            {
                int componentId = clsCommon.getComponentId(currentSubscription.Product.Handle);
                if (currentSubscription.State == SubscriptionState.Active)
                {
                    if (componentId > 0)
                    {
                        IComponentAttributes newInfo = chargify.GetComponentInfoForSubscription(currentSubscription.SubscriptionID, componentId);
                        usercount = Convert.ToInt32(newInfo.AllocatedQuantity + 1);
                    }
                }
                validpaid = true;
            }
            List <userLogin> users = (from u in db.userLogin where u.tenantId == tenantid && u.active == true select u).ToList();
            var tenantinfo         = (from obj in db.vw_Tenant
                                      where obj.tenantId == tenantid
                                      select new
            {
                paid = validpaid,
                Companyname = obj.companyName,
                AllocatedUsers = obj.allocatedUsers,
                address = obj.Address,
                owneremail = obj.email,
                codigoarea = obj.countryCode,
                phone = obj.number,
                ownerurl = obj.companyURL,
                //userscount = (from u in db.userLogin
                //              join ct in db.contact
                //              on u.contactId
                //              equals ct.contactId
                //              where u.tenantId == tenantid && u.active == true
                //              select new
                //              {
                //                  name = ct.name,
                //                  alias = u.userName,
                //                  email = ct.email
                //              }).ToList(),
                tenantconfigs = (from obj2 in db.genConfigName
                                 where obj2.genConfigNameGroupId == 1 && obj2.active == true
                                 orderby obj2.code ascending
                                 select new
                {
                    configNameid = obj2.genConfigNameId,
                    parameter = "",
                    active = obj2.active,
                    code = obj2.code
                }).ToList(),
                settconfigs = (from obj3 in db.genConfigName
                               where obj3.genConfigNameGroupId == 2 && obj3.active == true
                               orderby obj3.code ascending
                               select new
                {
                    configNameid = obj3.genConfigNameId,
                    parameter = "",
                    active = obj3.active,
                    code = obj3.code
                }).ToList(),
                languanges = (from obj4 in db.genLanguage select new { obj4.name }).ToList(),
                currencies = (from obj5 in db.genCurrency select new { obj5.name, code = obj5.code }).ToList(),
                regions = (from obj6 in db.genRegion select new { obj6.name }).ToList(),
                Timezones = (from obj7 in db.genTimezone select new { obj7.timeZone }).ToList(),
                defaultconfigs = (from dcn in db.genConfigName
                                  join dc in db.genConfig
                                  on dcn.genConfigNameId equals dc.genConfigNameId
                                  where dc.tenantId == tenantid && dcn.genConfigNameGroupId == 1 && dcn.active == true
                                  orderby dcn.code ascending
                                  select new
                {
                    dcn.code,
                    dc.parameter
                }).ToList(),
                settdefaultconfigs = (from dcn in db.genConfigName
                                      join dc in db.genConfig
                                      on dcn.genConfigNameId equals dc.genConfigNameId
                                      where dc.tenantId == tenantid && dcn.genConfigNameGroupId == 2 && dcn.active == true
                                      orderby dcn.code ascending
                                      select new
                {
                    dcn.code,
                    dc.parameter
                }).ToList(),
                userroles = (from urol in db.userLoginRole where (urol.userLoginRoleId != 1 && urol.userLoginRoleId != 2)select new { name = urol.name, id = urol.userLoginRoleId }).ToList()
            }).FirstOrDefault();

            if (tenantinfo != null)
            {
                result = Json(tenantinfo, JsonRequestBehavior.AllowGet);
            }

            return(result);
        }
예제 #11
0
        public ActionResult Subscribe(TestProject.Models.Subscribe subscribe, string confirmKey)
        {
            ChargifyConnect chargify = ChargifyTools.Chargify;
            string          plan     = subscribe.plan;
            bool            isCredit = subscribe.hasCreditCard || subscribe.creditcard.requireCredit;//ChargifyTools.RequireCreditCard(subscribe.plan);

            try
            {
                if (ChargifyTools.IsChargifyProduct(subscribe.plan))
                {
                    ViewBag.confirmKey = confirmKey;
                    ViewBag.plan       = subscribe.plan;
                    if (ValidatePassword(subscribe.password) == false)
                    {
                        //ViewBag.contactGenderId = new SelectList(db.contactGender.ToList(), "contactGenderId", "name");
                        ViewBag.Message = "Error password, you need a format that contains capital letters and numbers, example: Michael7.";
                        ViewBag.plan    = subscribe.plan;

                        return(View(subscribe));
                    }

                    userLogin user = new userLogin();
                    contact   cont = new contact();
                    tenant    tnt  = new tenant();
                    //----------------------------------------------------------------------------------------------------------------
                    //----------------------------------------------------------------------------------------------------------------
                    //----------------------------------------------------------------------------------------------------------------

                    tnt.tenantSubscriptionPlanId = (from pl in db.tenantSubscriptionPlan
                                                    where pl.code.ToLower().Equals(plan.ToLower())
                                                    select pl.tenantSubscriptionPlanId).FirstOrDefault();
                    tnt.active           = true;
                    tnt.allocatedUsers   = 1; //cantidad de usuarios asignados
                    tnt.billingRefNumber = Guid.NewGuid().ToString();
                    tnt.companyName      = subscribe.company;
                    tnt.companyURL       = "N/A";
                    tnt.database         = "TestProject";
                    tnt.tenantStatusId   = 2;
                    tnt.tenantSourceId   = 2;
                    if (isCredit)
                    {
                        tnt.tenentBillingTypeId = 1;
                    }
                    else
                    {
                        tnt.tenentBillingTypeId = 2;
                    }

                    /****** Valores quemados de campos auditoria*****/
                    tnt.updatedById    = 0;
                    tnt.createdById    = TntIdTestProject; // Id tenant TestProject
                    tnt.modifyDateTime = new DateTime(1900, 1, 1, 0, 0, 0);
                    tnt.insertDateTime = DateTime.Now;
                    /****** Valores quemados de campos auditoria*****/

                    db.tenant.Add(tnt);
                    db.SaveChanges();



                    var city = db.genCity
                               .Include(x => x.genState.genContry)
                               .SingleOrDefault(x => x.genCityId == Convert.ToInt32(subscribe.genCityId));
                    if (isCredit)
                    {
                        contactPhone phone = new contactPhone
                        {
                            active             = true,
                            number             = subscribe.phoneNumber,
                            contactId          = cont.contactId,
                            contactPhoneTypeId = 1,
                            tenantId           = tnt.tenantId,
                            updatedById        = 0,
                            createdById        = TntIdTestProject, // Id tenant TestProject
                            modifyDateTime     = new DateTime(1900, 1, 1, 0, 0, 0),
                            insertDateTime     = DateTime.Now
                        };

                        db.contactPhone.Add(phone);
                        db.SaveChanges();

                        cont.preferredBillAddressId = address.contactAddressId;
                        cont.preferredPhoneId       = phone.contactPhoneId;
                        db.Entry(cont).State        = EntityState.Modified;
                        db.SaveChanges();
                    }



                    /*** cosas de chargify!!!*/
                    CustomerAttributes customerInformation = new CustomerAttributes();
                    customerInformation.FirstName    = subscribe.firstName;
                    customerInformation.LastName     = subscribe.lastName;
                    customerInformation.Organization = subscribe.company;
                    customerInformation.Email        = subscribe.email;
                    // Create a new guid, this would be the Membership UserID if we were creating a new user simultaneously
                    customerInformation.SystemID = tnt.billingRefNumber;


                    ISubscription newSubscription = null;
                    string        productHandle   = plan;

                    if (isCredit)
                    {
                        CreditCardAttributes creditCardInfo = new CreditCardAttributes();

                        creditCardInfo.FullNumber      = subscribe.creditcard.creditCardNumber;
                        creditCardInfo.CVV             = subscribe.creditcard.cvv;
                        creditCardInfo.ExpirationMonth = subscribe.creditcard.ExpireMonth;
                        creditCardInfo.ExpirationYear  = subscribe.creditcard.ExpireYear;

                        creditCardInfo.BillingAddress = subscribe.street;
                        creditCardInfo.BillingCity    = city.City;//subscribe.city;
                        creditCardInfo.BillingState   = city.genState.State;
                        creditCardInfo.BillingZip     = subscribe.postalCode;
                        creditCardInfo.BillingCountry = city.genState.genContry.contry;

                        newSubscription = chargify.CreateSubscription(productHandle, customerInformation, creditCardInfo);
                    }
                    else
                    {
                        newSubscription = chargify.CreateSubscription(productHandle, customerInformation);
                    }
                }
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    System.Diagnostics.Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                       eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        System.Diagnostics.Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                                           ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
            catch (Exception e)
            {
                return(View(subscribe));
            }


            return(View(subscribe));
        }
        public House joinHouse(string houseName, string password, int userID)
        {
            using (var context = new houseMateEntities01())
            {
                if (getTID(userID) <= 0)
                {
                    int hID = Convert.ToInt32(context.houses
                        .Where(h => h.houseName.Equals(houseName) && h.password.Equals(password))
                        .Select(h => h.PK_houseID).FirstOrDefault());

                    tenant newTennant = new tenant
                    {
                        FK_houseID = hID,
                        FK_aspMemberID = userID
                    };
                    context.tenants.Add(newTennant);
                    context.SaveChanges();

                    return getHouse(userID);
                }
                else
                {
                    return new House(-1, "already in a house");
                }
            }
        }
예제 #13
0
        static void Main(string[] args)
        {
            using (var ctx = new ModelMateEFModel9Context())
            {
                ctx.Database.Log = Console.Write;
                Console.WriteLine("LazyLoadingEnabled: " + ctx.Configuration.LazyLoadingEnabled.ToString());

                foreach (tenant t in ctx.tenant)
                {
                    ModelDump.DisplayDBPropertyValues("t", ctx.Entry(t).CurrentValues, null);
                }

                //var query = from t in ctx.tenant
                //            where t.identifier == tident1
                //            select t;
                //tenant tq = query.Single();

                //object[] keysq = { tid };
                //tenant tq = ctx.tenant.Find(keysq);

                //ctx.Entry(tq).Collection(fs => fs.folders).Load(); // Works
                //folders fsq = tq.folders.ElementAt(0);
                //ModelMateLib.DisplayDBPropertyValues("fsq", ctx.Entry(fsq).CurrentValues, null);

                //ctx.Entry(fsq).Collection(f => f.folder).Load(); // Works
                //folder fq = fsq.folder.ElementAt(0);
                //ModelMateLib.DisplayDBPropertyValues("fq", ctx.Entry(fq).CurrentValues, null);

                //ctx.tenant.Load();
                object[] keys    = { tid };
                tenant   tenant9 = ctx.tenant.Find(keys);
                folders  fs0     = tenant9.folders.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("fs0", ctx.Entry(fs0).CurrentValues, null);
                folder f0 = fs0.folder.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("f0", ctx.Entry(f0).CurrentValues, null);



                //folders fs0 = t0.folders.ElementAt(0);
                //ModelMateLib.DisplayDBPropertyValues("fs0", ctx.Entry(fs0).CurrentValues, null);
                //folder f0 = fs0.folder.ElementAt(0);
                //ModelMateLib.DisplayDBPropertyValues("f0", ctx.Entry(f0).CurrentValues, null);

                tenant[] ts2 = new tenant[] { };
                ts2 = ModelFinder.FindTenants(ctx, tident2, "");
                ModelDump.DisplayDBPropertyValues("ts2", ctx.Entry(ts2[0]).CurrentValues, null);

                ts2 = ModelFinder.FindTenants(ctx, "", tname2);
                ModelDump.DisplayDBPropertyValues("ts2", ctx.Entry(ts2[0]).CurrentValues, null);

                tenant t2 = null;
                try
                {
                    t2 = ModelFinder.FindTenant(ctx, "", tname1);
                    ModelDump.DisplayDBPropertyValues("t1", ctx.Entry(t2).CurrentValues, null);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("EXCEPTION: " + ex.ToString());
                }

                //tenant t2 = null;
                try
                {
                    t2 = ModelFinder.FindTenant(ctx, tident1, "");
                    ModelDump.DisplayDBPropertyValues("t1", ctx.Entry(t2).CurrentValues, null);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("EXCEPTION: " + ex.ToString());
                }

                model m2 = ModelFinder.FindModel(ctx, t2, mident0, null);
                ModelDump.DisplayDBPropertyValues("m2", ctx.Entry(m2).CurrentValues, null);

                element[] es0 = ModelFinder.FindElements(ctx, t2, m2, ModelConst.ElementType.ApplicationComponent);
                Console.WriteLine("es0.Count: " + es0.Count <element>().ToString());
                ModelDump.DisplayDBPropertyValues("es0", ctx.Entry(es0[0]).CurrentValues, null);

                es0 = ModelFinder.FindElements(ctx, t2, m2, ModelConst.ElementType.AllElementTypes);
                Console.WriteLine("es0.Count: " + es0.Count <element>().ToString());
                ModelDump.DisplayDBPropertyValues("es0", ctx.Entry(es0[0]).CurrentValues, null);

                relationship[] rs0 = ModelFinder.FindRelationships(ctx, t2, m2, ModelConst.RelationshipType.AllRelationshipTypes);
                Console.WriteLine("es0.Count: " + es0.Count <element>().ToString());
                ModelDump.DisplayDBPropertyValues("es0", ctx.Entry(es0[0]).CurrentValues, null);

                foreach (relationship r in rs0)
                {
                    element eSource = ModelFinder.FindElement(ctx, t2, m2, r.source, null);
                    element eTarget = ModelFinder.FindElement(ctx, t2, m2, r.target, null);
                    ModelDump.DisplayDBPropertyValues("eSource", ctx.Entry(eSource).CurrentValues, null);
                    ModelDump.DisplayDBPropertyValues("r", ctx.Entry(r).CurrentValues, null);
                    ModelDump.DisplayDBPropertyValues("eTarget", ctx.Entry(eTarget).CurrentValues, null);
                }

                Console.WriteLine("Press enter to exit...");
                Console.ReadLine();
            }
        }
 InitializeConsumerConnection(tenant, product, component, topic, consumer.Name);
예제 #15
0
        static void Main(string[] args)
        {
            var models1 = new models
            {
                models_Id = Util.MakeIdInt32()
            };

            for (int iTimes = 0; iTimes < 10; iTimes++)
            {
                var model = new model
                {
                    identifier = Util.MakeIdentifierTimestamped(ModelConst.MODEL_PREFIX, DateTime.Now),
                    version    = ModelConst.MODEL_VERSION,
                    model_Id   = Util.MakeIdInt32()
                };
                models1.model.Add(model);
            }

            var models2 = new models
            {
                models_Id = Util.MakeIdInt32()
            };

            for (int iTimes = 0; iTimes < 10; iTimes++)
            {
                var model = new model
                {
                    identifier = Util.MakeIdentifierTimestamped(ModelConst.MODEL_PREFIX, DateTime.Now),
                    version    = ModelConst.MODEL_VERSION,
                    model_Id   = Util.MakeIdInt32()
                };
                models2.model.Add(model);
            }

            folder[] folderArray = new folder[2];
            folderArray[0] = new folder
            {
                identifier = Util.MakeIdentifierTimestamped(ModelConst.MODEL_PREFIX, DateTime.Now),
                folder_Id  = Util.MakeIdInt32()
            };
            folderArray[0].models.Add(models1); // NOTE: Models

            folderArray[1] = new folder
            {
                identifier = Util.MakeIdentifierTimestamped(ModelConst.MODEL_PREFIX, DateTime.Now),
                folder_Id  = Util.MakeIdInt32()
            };
            folderArray[1].models.Add(models2); // NOTE: Model Templates

            var folders = new folders
            {
                folders_Id = Util.MakeIdInt32()
            };

            for (int iTimes = 0; iTimes < 2; iTimes++)
            {
                var folder = folderArray[iTimes];
                folders.folder.Add(folder);
            }

            var tenant = new tenant
            {
                identifier = Util.MakeIdentifierTimestamped(ModelConst.TENANT_PREFIX, DateTime.Now),
                version    = ModelConst.TENANT_VERSION,
                tenant_Id  = Util.MakeIdInt32()
            };

            name name;

            name           = new name();
            name.name_Id   = Util.MakeIdInt32();
            name.lang      = "en";
            name.name_text = Util.MakeIdentifierTimestamped(ModelConst.TENANT_PREFIX);
            tenant.name.Add(name);

            name           = new name();
            name.name_Id   = Util.MakeIdInt32();
            name.lang      = "en";
            name.name_text = Util.MakeIdentifierTimestamped(ModelConst.TENANT_PREFIX);
            tenant.name.Add(name);

            tenant.folders.Add(folders);

            using (var context = new ModelMateEFModel9Context())
            {
                context.tenant.Add(tenant);
                context.SaveChanges();

                tenant.version = ModelConst.TENANT_TESTVERSION;

                context.SaveChanges();

                object[] keys         = { 1724588879 };
                tenant   tenantDelete = context.tenant.Find(keys);
                context.tenant.Remove(tenantDelete);
                context.SaveChanges();
            }

            Console.WriteLine("Press Enter to continue...");
            Console.ReadLine();
        }
예제 #16
0
        static void Main(string[] args)
        {
            string modelName = "Model 2 Test";

            ModelFactory.ModelName = modelName;

            //model modelArchisurance = ObjectFactory.NewModel("Archisurance");
            //DataSet dsArchisurance = new DataSet();
            //string xmlArchiSurance = @"..\..\..\PSN.ModelMate.Schema\Samples\Archisurance\Archisurance-psn.xml";
            //dsArchisurance.ReadXml(xmlArchiSurance);
            ////dsArchisurance.WriteXmlSchema("xmlArchiSurance.xsd");
            ////dsArchisurance.WriteXml("xmlArchiSurance.xml");
            //var mmpArchisurance = new ModelMateProcessor(ModelMateProcessor.ConvertAMEFFDataSet2Model);
            //// TODO TODO mmpArchisurance.ProcessModel(dsArchisurance, (DbContext)null, new Collection<model> { modelArchisurance });

            string tenantName = "Tenant 0 " + DateTime.Now.ToString();

            ModelFactory.TenantName = tenantName;

            var tenant0 = ModelFactory.NewTenantWithRootFolder(tenantName);

            tenantName = "Tenant 1 " + DateTime.Now.ToString();
            ModelFactory.TenantName = tenantName;

            var tenant1 = ModelFactory.NewTenant(tenantName,
                                                 ModelFactory.NewFolder("/",
                                                                        new folder[] { ModelFactory.NewFolder("Model Templates"), ModelFactory.NewFolder("Production Models") }
                                                                        )
                                                 );

            ModelConst.PropertyDataType dtStringType = ModelConst.PropertyDataType.stringType;
            propertydef  pdefString = ModelFactory.NewPropertyDef("String Propertydef " + DateTime.Now.ToString(), dtStringType);
            propertydefs pdefs      = ModelFactory.NewPropertyDefs(pdefString);

            ModelConst.ElementType etAC = ModelConst.ElementType.ApplicationComponent;
            element[] elementArray      = new element[10];
            for (int iElement = 0; iElement < 10; iElement++)
            {
                property p = ModelFactory.NewProperty(ModelFactory.NewValue("Element Property Value " + DateTime.Now.ToString()),
                                                      pdefString);
                elementArray[iElement] = ModelFactory.NewElement("Element " + iElement.ToString() + " " + DateTime.Now.ToString(), etAC, p);
            }
            elements elements = ModelFactory.NewElements(elementArray);

            tenantName = "Tenant 2 Test";
            ModelFactory.TenantName = tenantName;

            model model2;
            //var tenant2 = ModelFactory.NewTenant(tenantName,
            //                ModelFactory.NewFolder("/",
            //                    ModelFactory.NewFolder("Production Models",
            //                        ModelFactory.NewFolder("HQ Models Folder " + DateTime.Now.ToString(),
            //                            model2 = ModelFactory.NewModel(modelName, ModelConst.LANG_EN,
            //                                                            elements, pdefs
            //                            )
            //                        )
            //                    )
            //                )
            //              );

            var tenant2 = ModelFactory.NewTenant(tenantName,
                                                 ModelFactory.NewFolder("/",
                                                                        model2 = ModelFactory.NewModel(modelName, ModelConst.LANG_EN,
                                                                                                       elements, pdefs
                                                                                                       )
                                                                        )
                                                 );

            Console.WriteLine("Tenant.tenant_Id " + tenant2.tenant_Id.ToString());
            foreach (folders fs in tenant2.folders)
            {
                Console.WriteLine("Folders.tenant_Id " + fs.tenant_Id.ToString());
                Console.WriteLine("Folders.folders_Id " + fs.folders_Id.ToString());

                foreach (folder f in fs.folder)
                {
                    Console.WriteLine("Folder " + f.folders_Id.ToString());
                    Console.WriteLine("Folder " + f.folder_Id.ToString());
                }
            }

            var name = ModelFactory.NewName("Model 2 Name " + DateTime.Now.ToString());

            model2.name.Add(name);
            var documentation = ModelFactory.NewDocumentation("Model 2 Documentation " + DateTime.Now.ToString());

            model2.documentation.Add(documentation);
            var metadata = ModelFactory.NewMetadata(
                ModelFactory.NewProperty(ModelFactory.NewValue("Model 2 Metadata Value " + DateTime.Now.ToString()), pdefString)
                );

            model2.metadata.Add(metadata);

            var properties = ModelFactory.NewProperties(
                ModelFactory.NewProperty(ModelFactory.NewValue("Model 2 Property Value " + DateTime.Now.ToString()), pdefString)
                );

            model2.properties.Add(properties);

            var relationship1 = ModelFactory.NewRelationship("Association Relationship " + DateTime.Now.ToString(),
                                                             ModelConst.RelationshipType.AssociationRelationship,
                                                             elementArray[0], elementArray[1]
                                                             );
            var relationships = ModelFactory.NewRelationships(relationship1);

            model2.relationships.Add(relationships);

            var organization = ModelFactory.NewOrganization(
                ModelFactory.NewItem(elementArray[0],
                                     ModelFactory.NewItem(null,
                                                          ModelFactory.NewItem(elementArray[1]
                                                                               )
                                                          )
                                     )
                );

            model2.organization.Add(organization);

            var style1 = ModelFactory.NewStyle(
                ModelFactory.NewFillColor(255, 0, 0),
                ModelFactory.NewLineColor(0, 255, 0),
                ModelFactory.NewFont("Times Roman", (float)10.5, "bold", ModelFactory.NewColor(0, 0, 255)), 3
                );
            var style2 = ModelFactory.NewStyle(
                ModelFactory.NewFillColor(255, 0, 0),
                ModelFactory.NewLineColor(0, 255, 0),
                ModelFactory.NewFont("Times Roman", (float)12.5, "bold", ModelFactory.NewColor(0, 0, 255)), 3
                );

            var node0 = ModelFactory.NewNode("Node 0 " + DateTime.Now.ToString(),
                                             0, 0, 0, 50, 50, 50,
                                             elementArray[0], null, null, style1,
                                             new node[] { ModelFactory.NewNode("Sub Node " + DateTime.Now.ToString(),
                                                                               10, 10, 10, 25, 25, 25,
                                                                               elementArray[3]) }
                                             );
            var node1 = ModelFactory.NewNode("Node 1 " + DateTime.Now.ToString(),
                                             100, 100, 100, 50, 50, 50,
                                             elementArray[1], null, null, style2,
                                             null
                                             );

            var bendpoint1  = ModelFactory.NewBendPoint(25, 25, 25);
            var connection1 = ModelFactory.NewConnection("Connection 1 " + DateTime.Now.ToString(),
                                                         node0, node1, relationship1
                                                         );

            connection1.bendpoint.Add(bendpoint1);

            view view2;
            var  views = ModelFactory.NewViews(
                view2 = ModelFactory.NewView("View 2 " + DateTime.Now.ToString(), ModelConst.ViewType.Layered,
                                             new node[] {
                node0, node1
            },
                                             new connection[] { connection1 }
                                             )
                );

            model2.views.Add(views);

            tenant2.processinghistory.Add(
                ModelFactory.NewProcessinghistory(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );
            tenant2.usage.Add(
                ModelFactory.NewUsage(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );
            tenant2.performance.Add(
                ModelFactory.NewPerformance(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );
            tenant2.management.Add(
                ModelFactory.NewManagement(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );

            model2.processinghistory.Add(
                ModelFactory.NewProcessinghistory(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );
            model2.usage.Add(
                ModelFactory.NewUsage(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );
            model2.performance.Add(
                ModelFactory.NewPerformance(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );
            model2.management.Add(
                ModelFactory.NewManagement(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );

            elementArray[0].processinghistory.Add(
                ModelFactory.NewProcessinghistory(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );
            elementArray[0].usage.Add(
                ModelFactory.NewUsage(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );
            elementArray[0].performance.Add(
                ModelFactory.NewPerformance(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );
            elementArray[0].management.Add(
                ModelFactory.NewManagement(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );

            view2.processinghistory.Add(
                ModelFactory.NewProcessinghistory(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );
            view2.usage.Add(
                ModelFactory.NewUsage(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );
            view2.performance.Add(
                ModelFactory.NewPerformance(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );
            view2.management.Add(
                ModelFactory.NewManagement(
                    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(),
                                             ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(),
                                             null, null,
                                             ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
                                                                      )
                                             )
                    )
                );

            //using (XmlWriter writer = XmlWriter.Create("model2.xml"))
            //{
            //    //XmlSerializer serializer = new XmlSerializer(typeof(model));
            //    DataContractSerializerSettings settings = new DataContractSerializerSettings();
            //    DataContractSerializer serializer = new DataContractSerializer(typeof(model));
            //    serializer.WriteObject(writer, model2);
            //    writer.Close();
            //}

            string xmlSchemaFile = @"..\..\..\PSN.ModelMate.Schema\Schema\Reference ModelGood9.xsd";

            // DataSet ds = new DataSet();
            // ds.ReadXmlSchema(xmlSchemaFile);
            // BUG DataSet ds2 = new DataSet();
            // BUG ds2.ReadXmlSchema(xmlSchemaFile);

            //DataTable dttenant = ds.Tables["tenant"];
            //DataRow drtentant1 = dttenant.NewRow();
            //DataRow drtentant2 = ds.Tables["tenant"].NewRow();

            //DataTable dtfolders = ds.Tables["folders"];
            //DataTable dtfolder = ds.Tables["folder"];
            //DataTable dtmodels = ds.Tables["models"];
            //DataTable dtmodel = ds.Tables["model"];

            //DataTable dtprocessinghistory = ds.Tables["processinghistory"];
            //DataTable dtusage = ds.Tables["usage"];
            //DataTable dtperformance = ds.Tables["performance"];
            //DataTable dtmanagement = ds.Tables["management"];
            //DataTable dttimesnap = ds.Tables["timesnap"];

            //DataTable dtproperties = ds.Tables["properties"];
            //DataTable dtproperty = ds.Tables["property"];

            //DataTable dtpropertydefs = ds.Tables["propertydefs"];
            //DataTable dtpropertydef = ds.Tables["propertydef"];

            //DataTable dtelements = ds.Tables["elements"];
            //DataTable dtelement = ds.Tables["element"];

            //DataTable dtrelationships = ds.Tables["relationships"];
            //DataTable dtrelationship = ds.Tables["relationship"];

            //DataTable dtviews = ds.Tables["views"];
            //DataTable dtview = ds.Tables["view"];
            //DataTable dtconnection = ds.Tables["connection"];
            //DataTable dtnode = ds.Tables["node"];

            //DataTable dtstyle = ds.Tables["style"];
            //DataTable dtfont = ds.Tables["font"];
            //DataTable dtfillColor = ds.Tables["fillColor"];
            //DataTable dtlineColor = ds.Tables["lineColor"];
            //DataTable dtcolor = ds.Tables["color"];
            //DataTable dtbendpoint = ds.Tables["bendpoint"];

            //DataTable dtmetadata = ds.Tables["metadata"];

            //DataTable dtorganization = ds.Tables["organization"];
            //DataTable dtitem = ds.Tables["item"];

            //DataTable dtname = ds.Tables["name"];
            //DataTable dtvalue = ds.Tables["value"];
            //DataTable dtdocumentation = ds.Tables["documentation"];
            //DataTable dtlabel = ds.Tables["label"];

            using (var ctx = new ModelMateEFModel9Context())
            {
                ctx.Database.Log = Console.Write;

                ctx.tenant.Add(tenant0);
                ModelDump.DisplayTrackedEntities("Add tenant0", ctx.ChangeTracker);
                ctx.SaveChanges();
                ModelDump.DisplayTrackedEntities("Save tenant0", ctx.ChangeTracker);

                ctx.tenant.Add(tenant1);
                ctx.SaveChanges();

                ctx.tenant.Add(tenant2);
                ModelDump.DisplayTrackedEntities("Add tenant2", ctx.ChangeTracker);
                ctx.SaveChanges();
                ModelDump.DisplayTrackedEntities("Save tenant2", ctx.ChangeTracker);
                ModelDump.DisplayDBPropertyValues("tenant2", ctx.Entry(tenant2).CurrentValues, null);
                ModelDump.DisplayDBPropertyValues("model2", ctx.Entry(model2).CurrentValues, null);
                Console.WriteLine("Tenant.tenant_Id " + tenant2.tenant_Id.ToString());
                foreach (folders fs in tenant2.folders)
                {
                    Console.WriteLine("Folders.tenant_Id " + fs.tenant_Id.ToString());
                    Console.WriteLine("Folders.folders_Id " + fs.folders_Id.ToString());

                    foreach (folder f in fs.folder)
                    {
                        Console.WriteLine("Folder " + f.folders_Id.ToString());
                        Console.WriteLine("Folder " + f.folder_Id.ToString());
                    }
                }

                folders fs0 = tenant2.folders.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("fs0", ctx.Entry(fs0).CurrentValues, null);

                folder f0 = fs0.folder.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("f0", ctx.Entry(f0).CurrentValues, null);

                Console.WriteLine("RECURSION ==================================================");
                //DataSet dsTenant = new DataSet();
                //dsTenant.ReadXmlSchema(xmlSchemaFile);
                ////dsTenant.Tables["tenant"].Namespace = "http://www.w3.org/XML/1998/namespace";
                ////dsTenant.Tables["tenant"].Prefix = "xml";
                //var tenant = ctx.tenant.Find(new object[] { tenant2.tenant_Id });
                //var mmp = new ModelMateProcessor(ModelMateProcessor.ProcessObjectPopulateXMLDataSet);
                //mmp.ProcessTenant(dsTenant, (DbContext)ctx, new Collection<tenant> { tenant });
                //dsTenant.WriteXml("tentantds.xml");

                string  modelSchemaFile = @"..\..\..\PSN.ModelMate.Schema\Schema\ModelMateModel9.xsd";
                DataSet dsModel         = new DataSet();
                dsModel.ReadXmlSchema(modelSchemaFile);
                //DataSet ds3 = dsModel.Copy();
                //var mmpModel = new ModelMateProcessor();
                var mmpModel = new ModelProcessor(ModelProcessor.ConvertModel2AMEFFDataSet);
                mmpModel.ProcessModel(dsModel, (DbContext)ctx, new Collection <model> {
                    model2
                });
                dsModel.WriteXml("modelds.xml", XmlWriteMode.IgnoreSchema);
                string filename = "modelds2.xml";
                mmpModel.SaveAMEFFDataSetAsXML(dsModel, filename);

                tenant2.version = ModelConst.TENANT_TESTVERSION;
                var name2 = ModelFactory.NewName("Model Name FR " + DateTime.Now.ToString(), ModelConst.LANG_FR);
                model2.name.Add(name2);
                var name3 = ModelFactory.NewName("Model Name EN " + DateTime.Now.ToString());
                model2.name.Add(name3);
                ModelDump.DisplayTrackedEntities("Change tenant2", ctx.ChangeTracker);
                ctx.SaveChanges();
                ModelDump.DisplayTrackedEntities("Save tenant2", ctx.ChangeTracker);

                object[] keys    = { -1702823521 };
                tenant   tenant9 = ctx.tenant.Find(keys);
                //ctx.tenant.Remove(tenantDelete);
                //ctx.SaveChanges();
            }

            Console.WriteLine("Press enter to exist...");
            Console.ReadLine();
        }
예제 #17
0
        public ActionResult Index(FormCollection fc)
        {
            string type = fc["type"];//获取点击的是登录(管理员/业主/租户)还是注册

            if (type == "Register")
            {
                if (fc["loginacct"] == "" || fc["password"] == "" || fc["password1"] == "" || fc["accounttype"] == "")
                {
                    return(Content("<script>alert('注册账号时请填写全部信息');history.go(-1);</script>"));
                }
                else if (fc["password1"] != fc["password"])
                {
                    return(Content("<script>alert('密码与确认密码不一致!');history.go(-1);</script>"));
                }
                else
                {
                    string accounttype = fc["accounttype"];
                    string loginacct   = fc["loginacct"];
                    string password    = fc["password"];

                    if (accounttype == "type1")//系统管理员
                    {
                        var exist = db.propertycompany.FirstOrDefault(b => b.Pacct == loginacct);
                        if (exist != null)
                        {
                            return(Content("<script>alert('该账号已存在,请重新输入');history.go(-1);</script>"));
                        }
                        else
                        {
                            var newpropertycompany = new propertycompany()
                            {
                                Pacct = loginacct,
                                Ppass = password
                            };
                            db.propertycompany.Add(newpropertycompany);
                            db.SaveChanges();
                            return(Content("<script>alert('注册成功!');history.go(-1);</script>"));
                        }
                    }
                    else if (accounttype == "type2")//业主
                    {
                        var exist = db.owner.FirstOrDefault(b => b.Oacct == loginacct);
                        if (exist != null)
                        {
                            return(Content("<script>alert('该账号已存在,请重新输入');history.go(-1);</script>"));
                        }
                        else
                        {
                            var newowner = new owner()
                            {
                                Oacct = loginacct,
                                Opass = password
                            };
                            db.owner.Add(newowner);
                            db.SaveChanges();
                            return(Content("<script>alert('注册成功!');history.go(-1);</script>"));
                        }
                    }
                    else if (accounttype == "type3")//租户
                    {
                        var exist = db.tenant.FirstOrDefault(b => b.Tacct == loginacct);
                        if (exist != null)
                        {
                            return(Content("<script>alert('该账号已存在,请重新输入');history.go(-1);</script>"));
                        }
                        else
                        {
                            var newtenant = new tenant()
                            {
                                Tacct = loginacct,
                                Tpass = password
                            };
                            db.tenant.Add(newtenant);
                            db.SaveChanges();
                            return(Content("<script>alert('注册成功!');history.go(-1);</script>"));
                        }
                    }
                    else
                    {
                        return(Content("<script>alert('请选择账号类型');history.go(-1);</script>"));
                    }
                }
            }
            else//登录
            {
                if (type == "Manager")
                {
                    if (fc["loginacct"] == "" || fc["password"] == "")
                    {
                        return(Content("<script>alert('请输入账号密码');history.go(-1);</script>"));
                    }
                    else
                    {
                        string loginacct = fc["loginacct"];
                        string password  = fc["password"];

                        var com = db.propertycompany.Where(b => b.Pacct == loginacct & b.Ppass == password);
                        if (com.Count() > 0)
                        {
                            //用于当前页面参数传递,前台用<input id="taskType" name="taskType" type="hidden" value='@ViewBag.taskType' />取出
                            //ViewBag.displayname = loginacct;

                            //跳转不同界面的参数传递:
                            //return RedirectToAction(_cViewPage, new {taskType=taskType });
                            //<input id="taskType" name="taskType" type="hidden" value='@ViewData["taskType"]' />
                            //或者<input id="taskType" name="taskType" type="hidden" value='@Request.Params["taskType"]' />

                            Session.Add("user", com);


                            db.Dispose();

                            return(RedirectToAction("Index", "PropertyCompany", new { displayname = loginacct }));
                        }
                        else
                        {
                            db.Dispose();
                            return(Content("<script>alert('账号或密码错误!');history.go(-1);</script>"));
                        }
                    }
                }
                else if (type == "Owner")
                {
                    if (fc["loginacct"] == "" || fc["password"] == "")
                    {
                        return(Content("<script>alert('请输入账号密码');history.go(-1);</script>"));
                    }
                    else
                    {
                        string loginacct = fc["loginacct"];
                        string password  = fc["password"];

                        var com = db.owner.Where(b => b.Oacct == loginacct & b.Opass == password);
                        if (com.Count() > 0)
                        {
                            var oname = com.Select(b => b.Oname).FirstOrDefault();
                            if (oname == null)
                            {
                                Session["tocomplete"] = "";
                                // ViewBag.tocomplete = "";
                                Session["loginacct"] = loginacct;
                                Session["password"]  = password;
                            }
                            else
                            {
                                Session["tocomplete"] = "display:none";
                                // ViewBag.tocomplete = "display:none";
                            }
                            Session.Add("user", com);
                            db.Dispose();
                            return(RedirectToAction("Index", "Owner", new { displayname = oname }));
                        }
                        else
                        {
                            db.Dispose();
                            return(Content("<script>alert('账号或密码错误!');history.go(-1);</script>"));
                            //return Content("<script>lightyear.notify('账号或密码错误!', 'success', 5000, 'mdi mdi-emoticon-happy', 'top', 'center');</script>");
                        }
                    }
                }
                else if (type == "Tenant")
                {
                    if (fc["loginacct"] == "" || fc["password"] == "")
                    {
                        return(Content("<script>alert('请输入账号密码');history.go(-1);</script>"));
                    }
                    else
                    {
                        string loginacct = fc["loginacct"];
                        string password  = fc["password"];

                        var com = db.tenant.Where(b => b.Tacct == loginacct & b.Tpass == password);
                        if (com.Count() > 0)
                        {
                            var tname = com.Select(b => b.Tname).FirstOrDefault();
                            if (tname == null)
                            {
                                Session["tocomplete"] = "";
                                // ViewBag.tocomplete = "";
                                Session["loginacct"] = loginacct;
                                Session["password"]  = password;
                            }
                            else
                            {
                                Session["tocomplete"] = "display:none";
                                // ViewBag.tocomplete = "display:none";
                            }
                            Session.Add("user", com);
                            db.Dispose();
                            return(RedirectToAction("Index", "Tenant", new { displayname = tname }));
                        }
                        else
                        {
                            db.Dispose();
                            return(Content("<script>alert('账号或密码错误!');history.go(-1);</script>"));
                        }
                    }
                }
                else
                {
                    return(Content("<script>alert('发生未知的错误>_<');history.go(-1);</script>"));
                }
            }
        }
예제 #18
0
        static void Main(string[] args)
        {
            const string tTargetName       = "Tenant 2 Test";
            string       tTargetIdentifier = Util.MakeIdentifierRootIdentifier(typeof(tenant).Name, Util.TrimWhitespace(tTargetName));

            const string mTargetName       = "Model 2 Test";
            string       mTargetIdentifier = Util.MakeIdentifierFromParentIdentifier(
                Util.MakeIdentifierRootIdentifier(typeof(tenant).Name, tTargetName),
                typeof(model).Name, Util.TrimWhitespace(mTargetName));

            tenant tTarget = null;
            model  mTarget = null;

            using (var ctxTarget = new ModelMateEFModel9Context())
            {
                ctxTarget.Database.Log = Console.Write;
                Console.WriteLine("LazyLoadingEnabled: " + ctxTarget.Configuration.LazyLoadingEnabled.ToString());

                tTarget = ModelFinder.FindTenant(ctxTarget, tTargetIdentifier, "");
                ModelDump.DisplayDBPropertyValues("tTarget", ctxTarget.Entry(tTarget).CurrentValues, null);

                mTarget = ModelFinder.FindModel(ctxTarget, tTarget, mTargetIdentifier, null);
                ModelDump.DisplayDBPropertyValues("mTarget", ctxTarget.Entry(mTarget).CurrentValues, null);

                element[] es0 = ModelFinder.FindElements(ctxTarget, tTarget, mTarget, ModelConst.ElementType.ApplicationComponent);
                Console.WriteLine("es0.Count: " + es0.Count <element>().ToString());
                ModelDump.DisplayDBPropertyValues("es0", ctxTarget.Entry(es0[0]).CurrentValues, null);

                es0 = ModelFinder.FindElements(ctxTarget, tTarget, mTarget, ModelConst.ElementType.AllElementTypes);
                Console.WriteLine("es0.Count: " + es0.Count <element>().ToString());
                ModelDump.DisplayDBPropertyValues("es0", ctxTarget.Entry(es0[0]).CurrentValues, null);

                relationship[] rs0 = ModelFinder.FindRelationships(ctxTarget, tTarget, mTarget, ModelConst.RelationshipType.AllRelationshipTypes);
                Console.WriteLine("es0.Count: " + es0.Count <element>().ToString());
                ModelDump.DisplayDBPropertyValues("es0", ctxTarget.Entry(es0[0]).CurrentValues, null);

                foreach (relationship r in rs0)
                {
                    element eSource = ModelFinder.FindElement(ctxTarget, tTarget, mTarget, r.source, null);
                    element eTarget = ModelFinder.FindElement(ctxTarget, tTarget, mTarget, r.target, null);
                    ModelDump.DisplayDBPropertyValues("eSource", ctxTarget.Entry(eSource).CurrentValues, null);
                    ModelDump.DisplayDBPropertyValues("r", ctxTarget.Entry(r).CurrentValues, null);
                    ModelDump.DisplayDBPropertyValues("eTarget", ctxTarget.Entry(eTarget).CurrentValues, null);
                }
            }

            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();

            string tSourceName = "Tenant 2";

            ModelFactory.TenantName = tSourceName;

            string mSourceIdentifier = mTargetIdentifier;
            string mSourceName       = mTargetName; // "Model 2 " + DateTime.Now.ToString();

            ModelFactory.ModelName = mSourceName;

            tenant tSource = null;
            model  mSource = null;

            propertydef pdef1 = ModelFactory.NewPropertyDef("String Propertydef 1", ModelConst.PropertyDataType.stringType);
            propertydef pdef2 = ModelFactory.NewPropertyDef("Boolean Propertydef 2", ModelConst.PropertyDataType.booleanType);
            propertydef pdef3 = ModelFactory.NewPropertyDef("Number Propertydef 3", ModelConst.PropertyDataType.numberType);

            propertydef[] pdfArray = new propertydef[] { pdef1, pdef2, pdef3 };
            propertydefs  pdefs    = ModelFactory.NewPropertyDefs(pdfArray);

            ModelConst.ElementType etAC = ModelConst.ElementType.ApplicationComponent;
            element[] elementArray      = new element[10];
            for (int iElement = 0; iElement < 10; iElement++)
            {
                property p1 = ModelFactory.NewProperty(ModelFactory.NewValue("Element Property Value " + DateTime.Now.ToString()),
                                                       pdfArray[iElement % 3]);
                property p2 = ModelFactory.NewProperty(ModelFactory.NewValue("Element Property Value " + DateTime.Now.ToString()),
                                                       pdfArray[(iElement + 1) % 3]);
                properties ps = ModelFactory.NewProperties(new property[] { p1, p2 });
                elementArray[iElement] = ModelFactory.NewElement("Element " + iElement.ToString(), etAC, ps);
            }
            elements elements = ModelFactory.NewElements(elementArray);

            tSource = ModelFactory.NewTenant(tSourceName,
                                             ModelFactory.NewFolder("/",
                                                                    mSource = ModelFactory.NewModel(mSourceName, ModelConst.LANG_EN,
                                                                                                    elements, pdefs
                                                                                                    )
                                                                    )
                                             );

            mSource.version = "9.0";

            var properties = ModelFactory.NewProperties(ModelFactory.NewProperty(ModelFactory.NewValue("Model 2 Value 1"), pdef1));

            mSource.properties.Add(properties);

            //var name = ModelFactory.NewName("Model 2 Name " + DateTime.Now.ToString());
            //model3.name.Add(name);

            var relationship1 = ModelFactory.NewRelationship("Association Relationship 1",
                                                             ModelConst.RelationshipType.AssociationRelationship,
                                                             elementArray[0], elementArray[1]
                                                             );
            var relationship2 = ModelFactory.NewRelationship("Association Relationship 2",
                                                             ModelConst.RelationshipType.AssociationRelationship,
                                                             elementArray[2], elementArray[3]
                                                             );
            var relationships = ModelFactory.NewRelationships(new relationship[] { relationship1, relationship2 });

            mSource.relationships.Add(relationships);

            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();

            //var organization = ModelFactory.NewOrganization(
            //            ModelFactory.NewItem(elementArray[0],
            //                ModelFactory.NewItem(null,
            //                    ModelFactory.NewItem(elementArray[1]
            //                    )
            //                )
            //            )
            //       );
            //model3.organization.Add(organization);

            //var documentation = ModelFactory.NewDocumentation("Model 2 Documentation " + DateTime.Now.ToString());
            //model3.documentation.Add(documentation);

            //var metadata = ModelFactory.NewMetadata(
            //            ModelFactory.NewProperty(ModelFactory.NewValue("Model 2 Metadata Value " + DateTime.Now.ToString()), pdefString)
            //        );
            //model3.metadata.Add(metadata);

            //var style1 = ModelFactory.NewStyle(
            //                ModelFactory.NewFillColor(255, 0, 0),
            //                ModelFactory.NewLineColor(0, 255, 0),
            //                ModelFactory.NewFont("Times Roman", (float)10.5, "bold", ModelFactory.NewColor(0, 0, 255)), 3
            //            );
            //var style2 = ModelFactory.NewStyle(
            //    ModelFactory.NewFillColor(255, 0, 0),
            //    ModelFactory.NewLineColor(0, 255, 0),
            //    ModelFactory.NewFont("Times Roman", (float)12.5, "bold", ModelFactory.NewColor(0, 0, 255)), 3
            //);

            //var node0 = ModelFactory.NewNode("Node 0 " + DateTime.Now.ToString(),
            //                            0, 0, 0, 50, 50, 50,
            //                            elementArray[0], null, null, style1,
            //                            new node[] { ModelFactory.NewNode("Sub Node " + DateTime.Now.ToString(),
            //                                            10, 10, 10, 25, 25, 25,
            //                                            elementArray[3])
            //                            }
            //            );
            //var node1 = ModelFactory.NewNode("Node 1 " + DateTime.Now.ToString(),
            //                            100, 100, 100, 50, 50, 50,
            //                            elementArray[1], null, null, style2,
            //                            null
            //            );

            //var bendpoint1 = ModelFactory.NewBendPoint(25, 25, 25);
            //var connection1 = ModelFactory.NewConnection("Connection 1 " + DateTime.Now.ToString(),
            //                    node0, node1, relationship1
            //                  );
            //connection1.bendpoint.Add(bendpoint1);

            //view view2;
            //var views = ModelFactory.NewViews(
            //                view2 = ModelFactory.NewView("View 2 " + DateTime.Now.ToString(), ModelConst.ViewType.Layered,
            //                    new node[] {
            //                        node0, node1
            //                    },
            //                    new connection[] { connection1 }
            //                )
            //            );
            //model2.views.Add(views);

            //tenant2.processinghistory.Add(
            //ModelFactory.NewProcessinghistory(
            //    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(),
            //        ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(),
            //        null, null,
            //        ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //        )
            //    )
            //)
            //);
            //tenant2.usage.Add(
            //            ModelFactory.NewUsage(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //tenant2.performance.Add(
            //            ModelFactory.NewPerformance(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //tenant2.management.Add(
            //            ModelFactory.NewManagement(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );

            //model2.processinghistory.Add(
            //            ModelFactory.NewProcessinghistory(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //model2.usage.Add(
            //            ModelFactory.NewUsage(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //model2.performance.Add(
            //            ModelFactory.NewPerformance(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //model2.management.Add(
            //            ModelFactory.NewManagement(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );

            //elementArray[0].processinghistory.Add(
            //ModelFactory.NewProcessinghistory(
            //    ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(),
            //        ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(),
            //        null, null,
            //        ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //        )
            //    )
            //)
            //);
            //elementArray[0].usage.Add(
            //            ModelFactory.NewUsage(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //elementArray[0].performance.Add(
            //            ModelFactory.NewPerformance(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //elementArray[0].management.Add(
            //            ModelFactory.NewManagement(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );

            //view2.processinghistory.Add(
            //            ModelFactory.NewProcessinghistory(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Processinghistory " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.processinghistory, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //view2.usage.Add(
            //            ModelFactory.NewUsage(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.usage, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //view2.performance.Add(
            //            ModelFactory.NewPerformance(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Performance " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.performance, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );
            //view2.management.Add(
            //            ModelFactory.NewManagement(
            //                ModelFactory.NewTimesnap(DateTime.Now, "Timesnap Management " + DateTime.Now.ToString(),
            //                    ModelConst.TimesnapCategory.management, "Subcategory " + DateTime.Now.ToString(),
            //                    null, null,
            //                    ModelFactory.NewProperty(ModelFactory.NewValue("Value " + DateTime.Now.ToString()), pdefString
            //                    )
            //                )
            //            )
            //            );

            using (var ctxTarget = new ModelMateEFModel9Context())
            {
                ctxTarget.Database.Log = Console.Write;

                tTarget = ModelFinder.FindTenant(ctxTarget, tTargetIdentifier, "");
                ModelDump.DisplayDBPropertyValues("tTarget", ctxTarget.Entry(tTarget).CurrentValues, null);

                folders fs0 = tTarget.folders.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("fs0", ctxTarget.Entry(fs0).CurrentValues, null);
                folder f0 = fs0.folder.ElementAt(0);
                ModelDump.DisplayDBPropertyValues("f0", ctxTarget.Entry(f0).CurrentValues, null);

                mTarget = ModelFinder.FindModel(ctxTarget, tTarget, mTargetIdentifier, null);
                ModelDump.DisplayDBPropertyValues("mTarget", ctxTarget.Entry(mTarget).CurrentValues, null);

                ModelMigrator.MigrateModel(ctxTarget, tTarget, f0,
                                           mSource, PCOOperation.merge, PCOOperation.merge, true);
            }

            Console.WriteLine("Press enter to exist...");
            Console.ReadLine();
        }