Ejemplo n.º 1
0
        public Guid Create( BusinessEntity entity )
        {
            Guid id = Guid.NewGuid();

            string name = entity.GetType().Name;
            if( data.ContainsKey( name ) == false ) {
                data.Add( name, new BusinessEntityCollection() );
            }

            if( name == "DynamicEntity" ) {
                DynamicEntity de = ( DynamicEntity )entity;
                name = de.Name;
                de.Properties.Add( new KeyProperty( de.Name + "id", new Key( id ) ) );
            }
            else {
                entity.GetType().GetProperty( name + "id" ).SetValue( entity, new Key( id ), null );
            }

            if( !data.ContainsKey( name ) ) {
                data[ name ] = new BusinessEntityCollection();
            }
            data[ name ].BusinessEntities.Add( entity );

            if( m_persist ) {
                PersistToDisk( m_filename );
            }

            return id;
        }
Ejemplo n.º 2
0
		public void StandarRulesIsPersistable( )
		{
			var businessEntity = new BusinessEntity( );

			businessEntity.PersistenceRules.Add( new StandardRule<BusinessEntity>( e => e.Value > 5, "Value must be greater than 5.", "Value" ) );

			businessEntity.Value = 1;
			businessEntity.Value2 = 1;

			Assert.IsFalse( businessEntity.IsPersistable( ) );
			Assert.IsFalse( businessEntity.IsValid( ) );
		}
Ejemplo n.º 3
0
		public void CSharpRulesIsPersistable( )
		{
			IRulesFactory<BusinessEntity> factory = new CSharpRulesFactory<BusinessEntity>( );
			factory.AddRule( RuleType.Persistence, "e.Value > 5", "Value must be greater than 5.", "Value" );

			var businessEntity = new BusinessEntity( );
			businessEntity.PersistenceRules.Add( factory.FindRules( RuleType.Persistence ) );

			businessEntity.Value = 1;
			businessEntity.Value2 = 1;

			Assert.IsFalse( businessEntity.IsPersistable( ) );
			Assert.IsFalse( businessEntity.IsValid( ) );
		}
Ejemplo n.º 4
0
	public List<BusinessEntity> SelectEntity(int startIndex, int maxCount)
	{
		BusinessEntity item1 = new BusinessEntity();
		item1.Data1 = "Item 1";
		item1.Data2 = "Data 1";

		BusinessEntity item2 = new BusinessEntity();
		item2.Data1 = "Item 2";
		item2.Data2 = "Data 2";

		List<BusinessEntity> result = new List<BusinessEntity>(2);
		result.Add(item1);
		result.Add(item2);

		return result;
	}
Ejemplo n.º 5
0
        public List<BusinessEntity> GetMerchantMedia(Guid selectedUser)
        {
            List<BusinessEntity> mediaList = null;
            DataProvider.ExecuteCmd(GetConnection, "dbo.Medias_SelectMerchantImages"
               , inputParamMapper: delegate(SqlParameterCollection paramCollection)
               {
                   //  this is where your input params go. it works the same way as with ExecuteNonQuery.
                   paramCollection.AddWithValue("@Uid", selectedUser);
               }
            , map: delegate(IDataReader reader, short set)
            {
                BusinessEntity user = new BusinessEntity();
                int startingIndex = 0; //startingOrdinal

                user.Id = reader.GetSafeInt32(startingIndex++);
                user.Uid = reader.GetGuid(startingIndex++);
                user.Created = reader.GetDateTime(startingIndex++);
                user.Name = reader.GetSafeString(startingIndex++);
                user.ContactName = reader.GetSafeString(startingIndex++);
                user.Phone = reader.GetSafeString(startingIndex++);
                user.AddressId = reader.GetSafeInt32(startingIndex++);
                user.Url = reader.GetSafeString(startingIndex++);
                user.Slug = reader.GetSafeString(startingIndex++);
                user.ExternalCustomerId = reader.GetSafeString(startingIndex++);
                user.SubscriptionId = reader.GetSafeInt32(startingIndex++);

                user.Media = new Media();
                user.Media.ImageId = reader.GetSafeInt32(startingIndex++);
                user.Media.Path = reader.GetSafeString(startingIndex++);
                user.Media.DateCreated = reader.GetSafeDateTime(startingIndex++);
                user.Media.MediaEnum = reader.GetSafeEnum<MediaType>(startingIndex++);
                user.Media.User = reader.GetSafeEnum<UserType>(startingIndex++);
                user.Media.Description = reader.GetSafeString(startingIndex++);
                user.Media.Title = reader.GetSafeString(startingIndex++);
                user.Media.ContentType = reader.GetSafeString(startingIndex++);
                user.Media.FullPath = baseUrl + user.Media.Path;

                if (mediaList == null)
                {
                    mediaList = new List<BusinessEntity>();
                }

                mediaList.Add(user);
            }
               );
            return mediaList;
        }
Ejemplo n.º 6
0
 override internal DynamicQuery CreateDynamicQuery(BusinessEntity entity)
 {
     return(new VisualFoxProDynamicQuery(entity));
 }
Ejemplo n.º 7
0
        public async Task <IActionResult> Register(RegisterViewModel model, byte[] AvatarImage = null, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var roleAdmin = new IdentityRole("Admin");
                var roleuser  = new IdentityRole("User");

                // User claim for write task data
                user.Claims.Add(new IdentityUserClaim <string>
                {
                    ClaimType  = "Task",
                    ClaimValue = "Write"
                });


                var roleExists = _rolesManager.RoleExistsAsync(roleAdmin.Name).Result;


                if (!roleExists)
                {
                    var resulRoles = await _rolesManager.CreateAsync(roleAdmin);

                    if (resulRoles.Succeeded)
                    {
                        roleExists = _rolesManager.RoleExistsAsync(roleuser.Name).Result;
                        resulRoles = await _rolesManager.CreateAsync(roleuser);
                    }
                }

                var roleid = await _rolesManager.FindByNameAsync(roleAdmin.Name);

                user.Roles.Add(new IdentityUserRole <string>
                {
                    RoleId = roleid.Id,
                    UserId = user.Id
                });

                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    var businessEntity = new BusinessEntity(model.Name, model.Email, true);
                    var userSetting    = new UserSetting("", model.Name, "", "", businessEntity, user)
                    {
                        AvatarImage = AvatarImage, UserSettingId = user.Id
                    };
                    var userBusinessEntity = new UserBusinessEntity(businessEntity, userSetting);
                    _userBusinessEntityService.Add(userBusinessEntity);
                    //_userSettingService.Add(userSetting);

                    if (_pipelineService.Count() <= 0)
                    {
                        var pipeline = new Pipeline("Pipeline")
                        {
                            BusinessEntity = businessEntity, UserSettingId = user.Id
                        };
                        List <Stage>     stage     = new List <Stage>();
                        List <TaskGroup> taskGroup = new List <TaskGroup>();


                        stage.Add(new Stage()
                        {
                            BusinessEntity = businessEntity, Pipeline = pipeline, OrderStage = 1, Name = "Cliente potencial"
                        });
                        stage.Add(new Stage()
                        {
                            BusinessEntity = businessEntity, Pipeline = pipeline, OrderStage = 2, Name = "Contatado"
                        });
                        stage.Add(new Stage()
                        {
                            BusinessEntity = businessEntity, Pipeline = pipeline, OrderStage = 3, Name = "Demo Agendada"
                        });
                        stage.Add(new Stage()
                        {
                            BusinessEntity = businessEntity, Pipeline = pipeline, OrderStage = 4, Name = "Proposta Feita"
                        });
                        stage.Add(new Stage()
                        {
                            BusinessEntity = businessEntity, Pipeline = pipeline, OrderStage = 5, Name = "Negociações começadas"
                        });

                        taskGroup.Add(new TaskGroup()
                        {
                            BusinessEntity = businessEntity, Name = "Ligação"
                        });
                        taskGroup.Add(new TaskGroup()
                        {
                            BusinessEntity = businessEntity, Name = "Reunião"
                        });
                        taskGroup.Add(new TaskGroup()
                        {
                            BusinessEntity = businessEntity, Name = "Email"
                        });
                        taskGroup.Add(new TaskGroup()
                        {
                            BusinessEntity = businessEntity, Name = "Almoço"
                        });
                        taskGroup.Add(new TaskGroup()
                        {
                            BusinessEntity = businessEntity, Name = "Tarefa"
                        });
                        taskGroup.Add(new TaskGroup()
                        {
                            BusinessEntity = businessEntity, Name = "Apresentação"
                        });

                        _pipelineService.Add(pipeline);
                        stage.ForEach(a => _stageService.Add(a));
                        taskGroup.ForEach(a => _taskGroupService.Add(a));
                    }

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=532713
                    // Send an email with this link
                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.Action(nameof(ConfirmEmail), "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme);
                    await _emailSender.SendEmailAsync(model.Email, "Confirm your account",
                                                      $"<p>Por favor, confirme seu email clicando neste link : <a href='{callbackUrl}'>link</a>" + "</p>");

                    //await _signInManager.SignInAsync(user, isPersistent: false);
                    _logger.LogInformation(3, "User created a new account with password.");
                    return(RedirectToLocal(returnUrl));
                    //return RedirectToAction("Setup","Home", new { user = user });
                }

                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Ejemplo n.º 8
0
 public override int GetHashCode()
 {
     return(BusinessEntity.GetHashCode() ^ EmailAddressID.GetHashCode());
 }
        public BusinessEntity Add(BusinessEntity entity)
        {
            var id = _service.Store(entity);

            return(_service.Get(id));
        }
Ejemplo n.º 10
0
		public void CSharpRulesXmlFileIsPersistableAndIsValid( )
		{
			IRulesLoader<BusinessEntity, CSharpRulesFactory<BusinessEntity>> loader = new XmlRulesLoader<BusinessEntity, CSharpRulesFactory<BusinessEntity>>( );
			loader.AddRules( "csharpRules.xml" );

			var businessEntity = new BusinessEntity( );
			businessEntity.PersistenceRules.Add( loader.RulesFactory.FindRules( RuleType.Persistence ) );
			businessEntity.BusinessRules.Add( loader.RulesFactory.FindRules( RuleType.Business ) );

			businessEntity.Value = 6;
			businessEntity.Value2 = 6;
			businessEntity.Value3 = -2;
			businessEntity.Value4 = 7;
			businessEntity.Value5 = 7;

			Assert.IsFalse( businessEntity.IsPersistable( ) );
			Assert.IsFalse( businessEntity.IsValid( ) );
		}
Ejemplo n.º 11
0
 public static EntityAddedEvent For(BusinessEntity user)
 {
     return(new EntityAddedEvent(user.BusinessTestId, user.Version));
 }
Ejemplo n.º 12
0
 public AggregateClause(BusinessEntity entity)
 {
     this._entity = entity;
 }
Ejemplo n.º 13
0
 public int Store(BusinessEntity entity)
 {
     return(_repo.Add(entity));
 }
Ejemplo n.º 14
0
        private bool EvaluateLinks( ArrayList in_links, BusinessEntity in_entity )
        {
            // TODO: can we restructure things to avoid this check?
            if( in_links.Count == 0 ) return true;

            foreach( LinkEntity link in in_links ) {
                foreach( BusinessEntity entity in data[ link.LinkToEntityName ].BusinessEntities ) {

                    // TODO: we do this check and value retrieval in both filters and links handing
                    // TODO: we assume that both ends of the link are either DynamicEntity or not
                    object linkFromFieldValue = null;
                    object linkToFieldValue = null;
                    try { // another hack, since some entities will have null on the field we are linking
                        if( entity.GetType().Name == "DynamicEntity" ) {
                            // TODO: we only support StringProperty here
                            linkFromFieldValue = ( ( DynamicEntity )in_entity ).Properties[ link.LinkFromAttributeName ];
                            linkToFieldValue = ( ( DynamicEntity )entity ).Properties[ link.LinkToAttributeName ];
                        }
                        else {
                            linkFromFieldValue = in_entity.GetType().GetProperty( link.LinkFromAttributeName ).GetValue( in_entity, null );
                            linkToFieldValue = entity.GetType().GetProperty( link.LinkToAttributeName ).GetValue( entity, null );
                        }
                    }
                    catch { }
                    // TODO: are we passing the correct entity here? - do we need access to both entities to eval
                    // these criteria? Somehow I don't think so, since otherwise why would we need LinkEntity
                    // TODO: we only support inner join. CRM supports left outer and natural joins.
                    // TODO: how do we handle other comparisons that aren't Key == Lookup?
                    try { // Huge hack since we try to get Value of field that may be null
                        if( ( ( Key )linkFromFieldValue ).Value == ( ( Lookup )linkToFieldValue ).Value
                            && EvaluateFilters( link.LinkCriteria, entity ) == true ) {
                            // We short circuit - as long as one linked entity meets the criteria, we'll return true
                            // TODO: this is a bug - we don't eval all links.
                            return true;
                        }
                    }
                    catch { /// HACK try it the other way
                        try {
                            if( ( ( Lookup )linkFromFieldValue ).Value == ( ( Key )linkToFieldValue ).Value
                                && EvaluateFilters( link.LinkCriteria, entity ) == true ) {
                                // We short circuit - as long as one linked entity meets the criteria, we'll return true
                                // TODO: this is a bug - we don't eval all links.
                                return true;
                            }
                        }
                        catch { }
                    }
                }
                // TODO: eval nested links
                // EvaluateLinks( link.LinkEntities );
            }
            return false;
        }
Ejemplo n.º 15
0
        private bool EvaluateFilters( FilterExpression in_filter, BusinessEntity in_entity )
        {
            List<bool> results = new List<bool>();

            foreach( FilterExpression exp in in_filter.Filters ) {
                results.Add( EvaluateFilters( exp, in_entity ) );
            }
            foreach( ConditionExpression exp in in_filter.Conditions ) {
                bool result = true;
                object fieldValue;

                // TODO: extract this fieldvalue retrieval into a method
                if( in_entity.GetType().Name == "DynamicEntity" ) {
                    DynamicEntity entity = ( DynamicEntity )in_entity;
                    // TODO: we only support StringProperty here
                    fieldValue = entity.Properties[ exp.AttributeName ];
                }
                else {
                    fieldValue = in_entity.GetType().GetProperty( exp.AttributeName ).GetValue( in_entity, null );
                }

                if( exp.Operator == ConditionOperator.Equal ) {
                    foreach( object val in exp.Values ) {
                        // TODO: handle other data types
                        if( fieldValue is Key ) {
                            if( !val.Equals( ( ( Key )fieldValue).Value ) ) {
                                result = false;
                                break;
                            }
                        }
                        else {
                            if( !val.Equals( fieldValue ) ) {
                                result = false;
                                break;
                            }
                        }
                    }
                }
                results.Add( result );
            }

            bool retval;
            if( in_filter.FilterOperator == LogicalOperator.And ) {
                retval = true;
            }
            else {
                retval = false;
            }
            foreach( bool result in results ) {
                if( in_filter.FilterOperator == LogicalOperator.And ) {
                    retval = retval && result;
                }
                else {
                    retval = retval || result;
                }
            }
            return retval;
        }
Ejemplo n.º 16
0
        public void Update( BusinessEntity entity )
        {
            // Only support DynamicEntities for now
            DynamicEntity de = ( DynamicEntity )entity;
            foreach( BusinessEntity previousEntity in data[ de.Name ].BusinessEntities ) {
                // TODO: we assume id field is "entitynameid"
                if( previousEntity is DynamicEntity
                    && ( ( Key )( ( DynamicEntity )previousEntity ).Properties[ de.Name + "id" ] ).Value
                    == ( ( Key )de.Properties[ de.Name + "id" ] ).Value
                ) {
                    foreach( Property prop in de.Properties ) {
                        ( ( DynamicEntity )previousEntity ).Properties.Remove( prop.Name );
                        ( ( DynamicEntity )previousEntity ).Properties.Add( prop );
                    }
                    break;
                }
            }

            if( m_persist ) {
                PersistToDisk( m_filename );
            }
        }
 public VistaDBDynamicQuery(BusinessEntity entity)
     : base(entity)
 {
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Deletes the business entity.
        /// </summary>
        /// <param name="uConn">The UDDI connection.</param>
        /// <param name="bEntity">The business entity.</param>
        public static void DeleteBusinessEntity(UddiConnection uConn, BusinessEntity bEntity)
        {
            DeleteBusiness dBusiness = new DeleteBusiness(bEntity.BusinessKey);

            dBusiness.Send(uConn);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Saves the business entity.
        /// </summary>
        /// <param name="uConn">The UDDI connection.</param>
        /// <param name="bEntity">The business entity.</param>
        public static void SaveBusinessEntity(UddiConnection uConn, BusinessEntity bEntity)
        {
            SaveBusiness sBusiness = new SaveBusiness(bEntity);

            sBusiness.Send(uConn);
        }
 public void AddToBusinessEntity(BusinessEntity businessEntity)
 {
     base.AddObject("BusinessEntity", businessEntity);
 }
Ejemplo n.º 21
0
        public static void Clone(BaseEntity DestObj,
                                 BaseEntity SourceObj)
        {
            if (DestObj == null)
            {
                throw new ApplicationException("DestObj tidak boleh null");
            }
            TableDef td = GetTableDef(SourceObj.GetType());

            //IRuleInitUI px = DestObj as IRuleInitUI;
            //CallLoadRule = CallLoadRule && px != null;

            DestObj.EntityOnLoad = true;
            try
            {
                foreach (FieldDef fd in td.KeyFields.Values)
                {
                    fd.SetLoadValue(DestObj, fd.GetValue(SourceObj));
                }
                foreach (FieldDef fd in td.NonKeyFields.Values)
                {
                    fd.SetLoadValue(DestObj, fd.GetValue(SourceObj));
                }

                if (td.ChildEntities.Count > 0)
                {
                    foreach (EntityCollDef ecd in td.ChildEntities)
                    {
                        IList SrcCols  = ecd.GetValue(SourceObj);
                        IList DestCols = ecd.GetValue(DestObj);
                        int   NumDest  = DestCols.Count;
                        ((IEntityCollection)DestCols).OnLoad = true;

                        int i = 0;
                        while (DestCols.Count > SrcCols.Count)
                        {
                            DestCols.RemoveAt(0);
                        }
                        foreach (BaseEntity obj in SrcCols)
                        {
                            if (i < NumDest)
                            {
                                Clone((BaseEntity)DestCols[i++], obj);
                            }
                            else
                            {
                                DestCols.Add(Clone(obj));
                            }
                        }
                        ((IEntityCollection)DestCols).OnLoad = false;
                    }
                }
                //if (CallLoadRule)
                //{
                //    px.AfterLoadFound();
                //    BaseFramework.DoEntityAction(DestObj, enEntityActionMode.AfterLoadFound);
                //}
                BusinessEntity be = DestObj as BusinessEntity;
                if (be != null)
                {
                    be.AfterClone((BusinessEntity)SourceObj);
                }
            }
            finally
            {
                DestObj.EntityOnLoad = false;
                DestObj.DataChanged();
            }
        }
Ejemplo n.º 22
0
        public ActionResult Create(EmployeeViewModel EmployeeVm)
        {
            string[] ProcessIdArr;
            if (EmployeeVm.LedgerAccountGroupId == 0)
            {
                PrepareViewBag();
                return(View(EmployeeVm).Danger("Account Group field is required"));
            }

            if (_PersonService.CheckDuplicate(EmployeeVm.Name, EmployeeVm.Suffix, EmployeeVm.PersonId) == true)
            {
                PrepareViewBag();
                return(View(EmployeeVm).Danger("Combination of name and sufix is duplicate"));
            }


            if (ModelState.IsValid)
            {
                if (EmployeeVm.PersonId == 0)
                {
                    Person         person         = Mapper.Map <EmployeeViewModel, Person>(EmployeeVm);
                    BusinessEntity businessentity = Mapper.Map <EmployeeViewModel, BusinessEntity>(EmployeeVm);
                    Employee       Employee       = Mapper.Map <EmployeeViewModel, Employee>(EmployeeVm);
                    PersonAddress  personaddress  = Mapper.Map <EmployeeViewModel, PersonAddress>(EmployeeVm);
                    LedgerAccount  account        = Mapper.Map <EmployeeViewModel, LedgerAccount>(EmployeeVm);

                    person.DocTypeId    = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.Employee).DocumentTypeId;
                    person.CreatedDate  = DateTime.Now;
                    person.ModifiedDate = DateTime.Now;
                    person.CreatedBy    = User.Identity.Name;
                    person.ModifiedBy   = User.Identity.Name;
                    person.ObjectState  = Model.ObjectState.Added;
                    new PersonService(_unitOfWork).Create(person);

                    string Divisions = EmployeeVm.DivisionIds;
                    if (Divisions != null)
                    {
                        Divisions = "|" + Divisions.Replace(",", "|,|") + "|";
                    }

                    businessentity.DivisionIds = Divisions;

                    string Sites = EmployeeVm.SiteIds;
                    if (Sites != null)
                    {
                        Sites = "|" + Sites.Replace(",", "|,|") + "|";
                    }

                    businessentity.SiteIds = Sites;

                    _BusinessEntityService.Create(businessentity);
                    _EmployeeService.Create(Employee);


                    personaddress.AddressType  = AddressTypeConstants.Work;
                    personaddress.CreatedDate  = DateTime.Now;
                    personaddress.ModifiedDate = DateTime.Now;
                    personaddress.CreatedBy    = User.Identity.Name;
                    personaddress.ModifiedBy   = User.Identity.Name;
                    personaddress.ObjectState  = Model.ObjectState.Added;
                    _PersonAddressService.Create(personaddress);


                    account.LedgerAccountName   = person.Name;
                    account.LedgerAccountSuffix = person.Suffix;
                    account.CreatedDate         = DateTime.Now;
                    account.ModifiedDate        = DateTime.Now;
                    account.CreatedBy           = User.Identity.Name;
                    account.ModifiedBy          = User.Identity.Name;
                    account.ObjectState         = Model.ObjectState.Added;
                    _AccountService.Create(account);

                    if (EmployeeVm.ProcessIds != null && EmployeeVm.ProcessIds != "")
                    {
                        ProcessIdArr = EmployeeVm.ProcessIds.Split(new Char[] { ',' });

                        for (int i = 0; i <= ProcessIdArr.Length - 1; i++)
                        {
                            PersonProcess personprocess = new PersonProcess();
                            personprocess.PersonId     = Employee.PersonID;
                            personprocess.ProcessId    = Convert.ToInt32(ProcessIdArr[i]);
                            personprocess.CreatedDate  = DateTime.Now;
                            personprocess.ModifiedDate = DateTime.Now;
                            personprocess.CreatedBy    = User.Identity.Name;
                            personprocess.ModifiedBy   = User.Identity.Name;
                            personprocess.ObjectState  = Model.ObjectState.Added;
                            _PersonProcessService.Create(personprocess);
                        }
                    }

                    if (EmployeeVm.PanNo != "" && EmployeeVm.PanNo != null)
                    {
                        PersonRegistration personregistration = new PersonRegistration();
                        personregistration.RegistrationType = PersonRegistrationType.PANNo;
                        personregistration.RegistrationNo   = EmployeeVm.PanNo;
                        personregistration.CreatedDate      = DateTime.Now;
                        personregistration.ModifiedDate     = DateTime.Now;
                        personregistration.CreatedBy        = User.Identity.Name;
                        personregistration.ModifiedBy       = User.Identity.Name;
                        personregistration.ObjectState      = Model.ObjectState.Added;
                        _PersonRegistrationService.Create(personregistration);
                    }

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        PrepareViewBag();
                        return(View(EmployeeVm));
                    }


                    #region

                    //Saving Images if any uploaded after UnitOfWorkSave

                    if (Request.Files[0] != null && Request.Files[0].ContentLength > 0)
                    {
                        //For checking the first time if the folder exists or not-----------------------------
                        string uploadfolder;
                        int    MaxLimit;
                        int.TryParse(ConfigurationManager.AppSettings["MaxFileUploadLimit"], out MaxLimit);
                        var x = (from iid in db.Counter
                                 select iid).FirstOrDefault();
                        if (x == null)
                        {
                            uploadfolder = System.Guid.NewGuid().ToString();
                            Counter img = new Counter();
                            img.ImageFolderName = uploadfolder;
                            img.ModifiedBy      = User.Identity.Name;
                            img.CreatedBy       = User.Identity.Name;
                            img.ModifiedDate    = DateTime.Now;
                            img.CreatedDate     = DateTime.Now;
                            new CounterService(_unitOfWork).Create(img);
                            _unitOfWork.Save();
                        }

                        else
                        {
                            uploadfolder = x.ImageFolderName;
                        }


                        //For checking if the image contents length is greater than 100 then create a new folder------------------------------------

                        if (!Directory.Exists(System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder)))
                        {
                            Directory.CreateDirectory(System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder));
                        }

                        int count = Directory.GetFiles(System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder)).Length;

                        if (count >= MaxLimit)
                        {
                            uploadfolder = System.Guid.NewGuid().ToString();
                            var u = new CounterService(_unitOfWork).Find(x.CounterId);
                            u.ImageFolderName = uploadfolder;
                            new CounterService(_unitOfWork).Update(u);
                            _unitOfWork.Save();
                        }


                        //Saving Thumbnails images:
                        Dictionary <string, string> versions = new Dictionary <string, string>();

                        //Define the versions to generate
                        versions.Add("_thumb", "maxwidth=100&maxheight=100");  //Crop to square thumbnail
                        versions.Add("_medium", "maxwidth=200&maxheight=200"); //Fit inside 400x400 area, jpeg

                        string temp2    = "";
                        string filename = System.Guid.NewGuid().ToString();
                        foreach (string filekey in System.Web.HttpContext.Current.Request.Files.Keys)
                        {
                            HttpPostedFile pfile = System.Web.HttpContext.Current.Request.Files[filekey];
                            if (pfile.ContentLength <= 0)
                            {
                                continue;                           //Skip unused file controls.
                            }
                            temp2 = Path.GetExtension(pfile.FileName);

                            string uploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder);
                            if (!Directory.Exists(uploadFolder))
                            {
                                Directory.CreateDirectory(uploadFolder);
                            }

                            string filecontent = Path.Combine(uploadFolder, EmployeeVm.Name + "_" + filename);

                            //pfile.SaveAs(filecontent);
                            ImageBuilder.Current.Build(new ImageJob(pfile, filecontent, new Instructions(), false, true));


                            //Generate each version
                            foreach (string suffix in versions.Keys)
                            {
                                if (suffix == "_thumb")
                                {
                                    string tuploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder + "/Thumbs");
                                    if (!Directory.Exists(tuploadFolder))
                                    {
                                        Directory.CreateDirectory(tuploadFolder);
                                    }

                                    //Generate a filename (GUIDs are best).
                                    string tfileName = Path.Combine(tuploadFolder, EmployeeVm.Name + "_" + filename);

                                    //Let the image builder add the correct extension based on the output file type
                                    //fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true);
                                    ImageBuilder.Current.Build(new ImageJob(pfile, tfileName, new Instructions(versions[suffix]), false, true));
                                }
                                else if (suffix == "_medium")
                                {
                                    string tuploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder + "/Medium");
                                    if (!Directory.Exists(tuploadFolder))
                                    {
                                        Directory.CreateDirectory(tuploadFolder);
                                    }

                                    //Generate a filename (GUIDs are best).
                                    string tfileName = Path.Combine(tuploadFolder, EmployeeVm.Name + "_" + filename);

                                    //Let the image builder add the correct extension based on the output file type
                                    //fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true);
                                    ImageBuilder.Current.Build(new ImageJob(pfile, tfileName, new Instructions(versions[suffix]), false, true));
                                }
                            }

                            //var tempsave = _FinishedProductService.Find(pt.ProductId);

                            person.ImageFileName   = EmployeeVm.Name + "_" + filename + temp2;
                            person.ImageFolderName = uploadfolder;
                            person.ObjectState     = Model.ObjectState.Modified;
                            _PersonService.Update(person);
                            _unitOfWork.Save();
                        }
                    }

                    #endregion



                    //return RedirectToAction("Create").Success("Data saved successfully");
                    return(RedirectToAction("Edit", new { id = Employee.PersonID }).Success("Data saved Successfully"));
                }
                else
                {
                    //string tempredirect = (Request["Redirect"].ToString());
                    Person             person         = Mapper.Map <EmployeeViewModel, Person>(EmployeeVm);
                    BusinessEntity     businessentity = Mapper.Map <EmployeeViewModel, BusinessEntity>(EmployeeVm);
                    Employee           Employee       = Mapper.Map <EmployeeViewModel, Employee>(EmployeeVm);
                    PersonAddress      personaddress  = _PersonAddressService.Find(EmployeeVm.PersonAddressID);
                    LedgerAccount      account        = _AccountService.Find(EmployeeVm.AccountId);
                    PersonRegistration PersonPan      = _PersonRegistrationService.Find(EmployeeVm.PersonRegistrationPanNoID);

                    StringBuilder logstring = new StringBuilder();

                    person.ModifiedDate = DateTime.Now;
                    person.ModifiedBy   = User.Identity.Name;
                    new PersonService(_unitOfWork).Update(person);

                    string Divisions = EmployeeVm.DivisionIds;
                    if (Divisions != null)
                    {
                        Divisions = "|" + Divisions.Replace(",", "|,|") + "|";
                    }

                    businessentity.DivisionIds = Divisions;

                    string Sites = EmployeeVm.SiteIds;
                    if (Sites != null)
                    {
                        Sites = "|" + Sites.Replace(",", "|,|") + "|";
                    }

                    businessentity.SiteIds = Sites;


                    _BusinessEntityService.Update(businessentity);
                    _EmployeeService.Update(Employee);

                    personaddress.Address      = EmployeeVm.Address;
                    personaddress.CityId       = EmployeeVm.CityId;
                    personaddress.Zipcode      = EmployeeVm.Zipcode;
                    personaddress.ModifiedDate = DateTime.Now;
                    personaddress.ModifiedBy   = User.Identity.Name;
                    personaddress.ObjectState  = Model.ObjectState.Modified;
                    _PersonAddressService.Update(personaddress);

                    account.LedgerAccountName   = person.Name;
                    account.LedgerAccountSuffix = person.Suffix;
                    account.ModifiedDate        = DateTime.Now;
                    account.ModifiedBy          = User.Identity.Name;
                    _AccountService.Update(account);


                    if (EmployeeVm.ProcessIds != "" && EmployeeVm.ProcessIds != null)
                    {
                        IEnumerable <PersonProcess> personprocesslist = _PersonProcessService.GetPersonProcessList(EmployeeVm.PersonId);

                        foreach (PersonProcess item in personprocesslist)
                        {
                            new PersonProcessService(_unitOfWork).Delete(item.PersonProcessId);
                        }



                        ProcessIdArr = EmployeeVm.ProcessIds.Split(new Char[] { ',' });

                        for (int i = 0; i <= ProcessIdArr.Length - 1; i++)
                        {
                            PersonProcess personprocess = new PersonProcess();
                            personprocess.PersonId     = Employee.PersonID;
                            personprocess.ProcessId    = Convert.ToInt32(ProcessIdArr[i]);
                            personprocess.CreatedDate  = DateTime.Now;
                            personprocess.ModifiedDate = DateTime.Now;
                            personprocess.CreatedBy    = User.Identity.Name;
                            personprocess.ModifiedBy   = User.Identity.Name;
                            personprocess.ObjectState  = Model.ObjectState.Added;
                            _PersonProcessService.Create(personprocess);
                        }
                    }


                    if (EmployeeVm.PanNo != null && EmployeeVm.PanNo != "")
                    {
                        if (PersonPan != null)
                        {
                            PersonPan.RegistrationNo = EmployeeVm.PanNo;
                            _PersonRegistrationService.Update(PersonPan);
                        }
                        else
                        {
                            PersonRegistration personregistration = new PersonRegistration();
                            personregistration.PersonId         = EmployeeVm.PersonId;
                            personregistration.RegistrationType = PersonRegistrationType.PANNo;
                            personregistration.RegistrationNo   = EmployeeVm.PanNo;
                            personregistration.CreatedDate      = DateTime.Now;
                            personregistration.ModifiedDate     = DateTime.Now;
                            personregistration.CreatedBy        = User.Identity.Name;
                            personregistration.ModifiedBy       = User.Identity.Name;
                            personregistration.ObjectState      = Model.ObjectState.Added;
                            _PersonRegistrationService.Create(personregistration);
                        }
                    }



                    ////Saving Activity Log::
                    ActivityLog al = new ActivityLog()
                    {
                        ActivityType = (int)ActivityTypeContants.Modified,
                        DocId        = EmployeeVm.PersonId,
                        Narration    = logstring.ToString(),
                        CreatedDate  = DateTime.Now,
                        CreatedBy    = User.Identity.Name,
                        //DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(TransactionDocCategoryConstants.ProcessSequence).DocumentTypeId,
                    };
                    new ActivityLogService(_unitOfWork).Create(al);
                    //End of Saving ActivityLog

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        PrepareViewBag();
                        return(View("Create", EmployeeVm));
                    }



                    #region

                    //Saving Image if file is uploaded
                    if (Request.Files[0] != null && Request.Files[0].ContentLength > 0)
                    {
                        string uploadfolder = EmployeeVm.ImageFolderName;
                        string tempfilename = EmployeeVm.ImageFileName;
                        if (uploadfolder == null)
                        {
                            var x = (from iid in db.Counter
                                     select iid).FirstOrDefault();
                            if (x == null)
                            {
                                uploadfolder = System.Guid.NewGuid().ToString();
                                Counter img = new Counter();
                                img.ImageFolderName = uploadfolder;
                                img.ModifiedBy      = User.Identity.Name;
                                img.CreatedBy       = User.Identity.Name;
                                img.ModifiedDate    = DateTime.Now;
                                img.CreatedDate     = DateTime.Now;
                                new CounterService(_unitOfWork).Create(img);
                                _unitOfWork.Save();
                            }
                            else
                            {
                                uploadfolder = x.ImageFolderName;
                            }
                        }
                        //Deleting Existing Images

                        var xtemp = System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/" + tempfilename);
                        if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/" + tempfilename)))
                        {
                            System.IO.File.Delete(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/" + tempfilename));
                        }

                        //Deleting Thumbnail Image:

                        if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/Thumbs/" + tempfilename)))
                        {
                            System.IO.File.Delete(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/Thumbs/" + tempfilename));
                        }

                        //Deleting Medium Image:
                        if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/Medium/" + tempfilename)))
                        {
                            System.IO.File.Delete(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/Medium/" + tempfilename));
                        }

                        //Saving Thumbnails images:
                        Dictionary <string, string> versions = new Dictionary <string, string>();

                        //Define the versions to generate
                        versions.Add("_thumb", "maxwidth=100&maxheight=100");  //Crop to square thumbnail
                        versions.Add("_medium", "maxwidth=200&maxheight=200"); //Fit inside 400x400 area, jpeg

                        string temp2    = "";
                        string filename = System.Guid.NewGuid().ToString();
                        foreach (string filekey in System.Web.HttpContext.Current.Request.Files.Keys)
                        {
                            HttpPostedFile pfile = System.Web.HttpContext.Current.Request.Files[filekey];
                            if (pfile.ContentLength <= 0)
                            {
                                continue;                           //Skip unused file controls.
                            }
                            temp2 = Path.GetExtension(pfile.FileName);

                            string uploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder);
                            if (!Directory.Exists(uploadFolder))
                            {
                                Directory.CreateDirectory(uploadFolder);
                            }

                            string filecontent = Path.Combine(uploadFolder, EmployeeVm.Name + "_" + filename);

                            //pfile.SaveAs(filecontent);

                            ImageBuilder.Current.Build(new ImageJob(pfile, filecontent, new Instructions(), false, true));

                            //Generate each version
                            foreach (string suffix in versions.Keys)
                            {
                                if (suffix == "_thumb")
                                {
                                    string tuploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder + "/Thumbs");
                                    if (!Directory.Exists(tuploadFolder))
                                    {
                                        Directory.CreateDirectory(tuploadFolder);
                                    }

                                    //Generate a filename (GUIDs are best).
                                    string tfileName = Path.Combine(tuploadFolder, EmployeeVm.Name + "_" + filename);

                                    //Let the image builder add the correct extension based on the output file type
                                    //fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true);
                                    ImageBuilder.Current.Build(new ImageJob(pfile, tfileName, new Instructions(versions[suffix]), false, true));
                                }
                                else if (suffix == "_medium")
                                {
                                    string tuploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder + "/Medium");
                                    if (!Directory.Exists(tuploadFolder))
                                    {
                                        Directory.CreateDirectory(tuploadFolder);
                                    }

                                    //Generate a filename (GUIDs are best).
                                    string tfileName = Path.Combine(tuploadFolder, EmployeeVm.Name + "_" + filename);

                                    //Let the image builder add the correct extension based on the output file type
                                    //fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true);
                                    ImageBuilder.Current.Build(new ImageJob(pfile, tfileName, new Instructions(versions[suffix]), false, true));
                                }
                            }
                        }
                        var temsave = _PersonService.Find(person.PersonID);
                        person.ImageFileName    = temsave.Name + "_" + filename + temp2;
                        temsave.ImageFolderName = uploadfolder;
                        _PersonService.Update(temsave);
                        _unitOfWork.Save();
                    }

                    #endregion



                    return(RedirectToAction("Index").Success("Data saved successfully"));
                }
            }
            PrepareViewBag();
            return(View(EmployeeVm));
        }
 void IEntityCollection.Init(BusinessEntity Parent, string ChildName)
 {
     _Parent    = Parent;
     _ChildName = ChildName;
 }
Ejemplo n.º 24
0
        public ActionResult DeleteConfirmed(ReasonViewModel vm)
        {
            if (ModelState.IsValid)
            {
                Person         person         = new PersonService(_unitOfWork).Find(vm.id);
                BusinessEntity businessentiry = _BusinessEntityService.Find(vm.id);
                Employee       Employee       = _EmployeeService.Find(vm.id);

                ActivityLog al = new ActivityLog()
                {
                    ActivityType = (int)ActivityTypeContants.Deleted,
                    CreatedBy    = User.Identity.Name,
                    CreatedDate  = DateTime.Now,
                    DocId        = vm.id,
                    UserRemark   = vm.Reason,
                    Narration    = "Employee is deleted with Name:" + person.Name,
                    DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(TransactionDocCategoryConstants.SaleOrder).DocumentTypeId,
                    UploadDate   = DateTime.Now,
                };
                new ActivityLogService(_unitOfWork).Create(al);

                //Then find Ledger Account associated with the above Person.
                LedgerAccount ledgeraccount = _AccountService.GetLedgerAccountFromPersonId(vm.id);
                _AccountService.Delete(ledgeraccount.LedgerAccountId);

                //Then find all the Person Address associated with the above Person.
                PersonAddress personaddress = _PersonAddressService.GetShipAddressByPersonId(vm.id);
                _PersonAddressService.Delete(personaddress.PersonAddressID);


                IEnumerable <PersonContact> personcontact = new PersonContactService(_unitOfWork).GetPersonContactIdListByPersonId(vm.id);
                //Mark ObjectState.Delete to all the Person Contact For Above Person.
                foreach (PersonContact item in personcontact)
                {
                    new PersonContactService(_unitOfWork).Delete(item.PersonContactID);
                }

                IEnumerable <PersonBankAccount> personbankaccount = new PersonBankAccountService(_unitOfWork).GetPersonBankAccountIdListByPersonId(vm.id);
                //Mark ObjectState.Delete to all the Person Contact For Above Person.
                foreach (PersonBankAccount item in personbankaccount)
                {
                    new PersonBankAccountService(_unitOfWork).Delete(item.PersonBankAccountID);
                }


                IEnumerable <PersonProcess> personProcess = new PersonProcessService(_unitOfWork).GetPersonProcessIdListByPersonId(vm.id);
                //Mark ObjectState.Delete to all the Person Process For Above Person.
                foreach (PersonProcess item in personProcess)
                {
                    new PersonProcessService(_unitOfWork).Delete(item.PersonProcessId);
                }


                IEnumerable <PersonRegistration> personregistration = new PersonRegistrationService(_unitOfWork).GetPersonRegistrationIdListByPersonId(vm.id);
                //Mark ObjectState.Delete to all the Person Registration For Above Person.
                foreach (PersonRegistration item in personregistration)
                {
                    new PersonRegistrationService(_unitOfWork).Delete(item.PersonRegistrationID);
                }


                // Now delete the Parent Employee
                _EmployeeService.Delete(Employee);
                _BusinessEntityService.Delete(businessentiry);
                new PersonService(_unitOfWork).Delete(person);


                try
                {
                    _unitOfWork.Save();
                }

                catch (Exception ex)
                {
                    string message = _exception.HandleException(ex);
                    ModelState.AddModelError("", message);
                    return(PartialView("_Reason", vm));
                }
                return(Json(new { success = true }));
            }
            return(PartialView("_Reason", vm));
        }
Ejemplo n.º 25
0
		public void PythonRulesXmlFileIsPersistable( )
		{
			IRulesLoader<BusinessEntity, PythonRulesFactory<BusinessEntity>> loader = new XmlRulesLoader<BusinessEntity, PythonRulesFactory<BusinessEntity>>( );
			loader.AddRules( "pythonRules.xml" );

			var businessEntity = new BusinessEntity( );
			businessEntity.PersistenceRules.Add( loader.RulesFactory.FindRules( RuleType.Persistence ) );
			businessEntity.BusinessRules.Add( loader.RulesFactory.FindRules( RuleType.Business ) );

			businessEntity.Value = 6;
			businessEntity.Value2 = 1;

			Assert.IsTrue( businessEntity.IsPersistable( ) );
			Assert.IsFalse( businessEntity.IsValid( ) );
		}
 protected override void onChildDataChanged(string ChildName, BusinessEntity ChildObject)
 {
     _TotalNilai = PenerimaanKasDetil.Sum("NilaiPenerimaan");
     DataChanged();
 }
Ejemplo n.º 27
0
		public void CSharpRulesXmlFileComplexIsPersistable( )
		{
			IRulesLoader<BusinessEntity, CSharpRulesFactory<BusinessEntity>> loader = new XmlRulesLoader<BusinessEntity, CSharpRulesFactory<BusinessEntity>>( );
			loader.AddRules( "csharpRules.xml" );

			var businessEntity = new BusinessEntity( );
			businessEntity.PersistenceRules.Add( loader.RulesFactory.FindRules( RuleType.Persistence ) );
			businessEntity.BusinessRules.Add( loader.RulesFactory.FindRules( RuleType.Business ) );

			businessEntity.Value = 6;
			businessEntity.Value2 = 6;
			businessEntity.Value3 = 0;
			businessEntity.Value4 = 6;
			businessEntity.Value5 = 6;

			Assert.IsFalse( businessEntity.IsPersistable( ) );

			List<BrokenRuleData> brokenRules = new List<BrokenRuleData>( );
			brokenRules.AddRange( businessEntity.GetAllBrokenRules( ) );

			Assert.AreEqual<int>( 1, brokenRules.Count );

			List<string> brokenRuleProperties = new List<string>( );
			brokenRuleProperties.AddRange( brokenRules[ 0 ].Properties );

			Assert.AreEqual<int>( 2, brokenRuleProperties.Count );

			Assert.AreEqual<string>( "Value4", brokenRuleProperties[ 0 ] );
			Assert.AreEqual<string>( "Value5", brokenRuleProperties[ 1 ] );
		}
 /// <summary>
 /// Creates the specified entity.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <returns></returns>
 public virtual Guid Create(BusinessEntity entity)
 {
     return(ID.Null.Guid);
 }
 /// <summary>
 /// Updates the specified entity.
 /// </summary>
 /// <param name="entity">The entity.</param>
 public virtual void Update(BusinessEntity entity)
 {
 }
Ejemplo n.º 30
0
 public Guid Create(BusinessEntity entity)
 {
     this.Validate();
     return(this.CrmService.Create(entity));
 }
Ejemplo n.º 31
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        BusinessEntity.PushStaticConnectionString();

        BusinessEntity.StaticConnectionString = ConfigurationSettings.AppSettings["dbConnection"];

        DL_WEB.DAL.Master.Organization oOrganization = new DL_WEB.DAL.Master.Organization();
        oOrganization.LoadByPrimaryKey(OrganizationID);

        DL_WEB.DAL.Master.Database oDatabase = new DL_WEB.DAL.Master.Database();
        if (oOrganization.RowCount > 0)
        {
            oDatabase.LoadByPrimaryKey(oOrganization.DatabaseID);
        }

        DL_WEB.DAL.Master.Server oServer = new DL_WEB.DAL.Master.Server();
        if (oDatabase.RowCount > 0)
        {
            oServer.LoadByPrimaryKey(oDatabase.ServerID);

            MyGeneration.dOOdads.BusinessEntity.StaticConnectionString = oDatabase.DBConnectionString;
        }

        AddressBook oAddressBook = new AddressBook();

        oAddressBook.AddNew();
        oAddressBook.FirstName    = tbFirstName.Text;
        oAddressBook.LastName     = tbLastName.Text;
        oAddressBook.Company      = tbCompany.Text;
        oAddressBook.PrimaryEmail = tbEmail.Text;
        oAddressBook.ProjectID    = this.ProjectID;
        oAddressBook.IsApproved   = false;
        oAddressBook.GUID         = Guid.NewGuid();
        oAddressBook.Save();

        ProjectNotification oProjectNotification = new ProjectNotification();

        oProjectNotification.AddNew();
        oProjectNotification.AddressBookEntryID = oAddressBook.EntryID;
        oProjectNotification.ProjectID          = this.ProjectID;
        oProjectNotification.ImpactLevelID      = Micajah.Common.Helper.Convert.o2i(this.ImpactLevelList.SelectedValue);
        oProjectNotification.NotificationTypeID = 1;
        oProjectNotification.Save();

        BusinessEntity.PopStaticConnectionString();

        #region Sending confirmation request to this contact

        SmtpClient client = new SmtpClient(oServer.MailHost);
        client.Credentials = new NetworkCredential(oServer.MailUser, oServer.MailPass);

        MailAddress from    = new MailAddress(oServer.MailEmail, "Deployment Logger");
        MailAddress to      = new MailAddress(tbEmail.Text, tbFirstName.Text + " " + tbLastName.Text);
        MailMessage message = new MailMessage(from, to);

        message.Subject = "Welcome to Deployment Logger";
        message.Body    = String.Format("Dear, {3},\n\nThank you for registering with Deployment Logger.\n" +
                                        "To activate your account and verify your e-mail address, please click on the following link:\n" +
                                        "{0}anonymous/SubscribeConfirmation.aspx?addressbookid={1}&databaseid={2}&guid={4}\n\n" +
                                        "If you have received this mail in error, you do not need to take any action to cancel the account. " +
                                        "The account will not be activated, and you will not receive any further emails.\n\n" +
                                        "If clicking the link above does not work, copy and paste the URL in a new browser window instead.\n\n" +
                                        "Thank you for using Micajah Deployment Logger!" +
                                        "---" +
                                        "This is a post-only mailing.  Replies to this message are not monitored or answered.", oServer.WebReference, oAddressBook.EntryID, oDatabase.DatabaseID, tbFirstName.Text + " " + tbLastName.Text, HttpUtility.UrlEncode(oAddressBook.GUID.ToString()));
        client.Send(message);
        message.Dispose();

        #endregion
    }
Ejemplo n.º 32
0
 public void Update(BusinessEntity entity)
 {
     this.Validate();
     this.CrmService.Update(entity);
 }
Ejemplo n.º 33
0
        /// <summary>Returns the value of a field in the specified table of the specified DataSet</summary>
        /// <typeparam name="TField">The expected returned type for the field.</typeparam>
        /// <param name="entity">The business entity the field belongs to.</param>
        /// <param name="dataSet">The data set the field lives in.</param>
        /// <param name="tableName">Name of the table containing the field.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="dataRow">The data row.</param>
        /// <param name="ignoreNulls">Should null values be ignored and returned as null (true) or should they be turned into default values (false)?</param>
        /// <returns>Field value (or type default in exception scenarios)</returns>
        public static TField GetFieldValue <TField>(BusinessEntity entity, DataSet dataSet, string tableName, string fieldName, DataRow dataRow, bool ignoreNulls)
        {
            if (entity == null)
            {
                throw new NullReferenceException("Parameter 'entity' cannot be null or empty.");
            }
            if (dataSet == null)
            {
                throw new NullReferenceException("Parameter 'dataSet' cannot be null or empty.");
            }
            if (string.IsNullOrEmpty(tableName))
            {
                throw new NullReferenceException("Parameter 'tableName' cannot be null or empty.");
            }
            if (string.IsNullOrEmpty(fieldName))
            {
                throw new NullReferenceException("Parameter 'fieldName' cannot be null or empty.");
            }
            if (dataRow == null)
            {
                throw new NullReferenceException("Parameter 'dataRow' cannot be null or empty.");
            }

            // We get the mapped names
            // If there's no mapping for the field, we get an empty string.
            // If that's the case, we must keep going with the fieldName that's
            // been passed, otherwise CheckColumn looks for empty string, which
            // ends up throwing an exception saying that "column '' can't be found" or something...
            var internalFieldName = entity.GetInternalFieldName(fieldName, tableName);

            if (!string.IsNullOrEmpty(internalFieldName))
            {
                fieldName = internalFieldName;
            }

            tableName = entity.GetInternalTableName(tableName);

            // We make sure the column exists, and then immediately return its value
            if (!CheckColumn(dataSet, fieldName, tableName))
            {
                throw new FieldDoesntExistException("Field doesn't exist.")
                      {
                          Source = fieldName + "." + tableName
                      }
            }
            ;

            // We check for null values...
            if (!ignoreNulls)
            {
                if (dataRow[fieldName] == DBNull.Value)
                {
                    return((TField)GenerateDefaultValueForColumn(dataSet.Tables[tableName].Columns[fieldName]));
                }
            }

            try
            {
                // No null values found. We return the actual value
                // However, we do check to see if this is a DateTime field, because if so, we do some transformations.
                if (dataSet.Tables[tableName].Columns[fieldName].DataType == typeof(DateTime))
                {
                    //DateTime datValue = (DateTime)dsInternal.Tables[tableName].Rows[0][fieldName];
                    var currentBusinessObject = entity.AssociatedBusinessObject;
                    if (currentBusinessObject is BusinessObject currentBusinessObject2)
                    {
                        var currentService = currentBusinessObject2.DataService;
                        var currentDate    = (DateTime)dataRow[fieldName];
                        if (currentDate == currentService.DateMinValue)
                        {
                            // This field contains the minimum date value of the current database.
                            // We convert it to .NET's minimum date value
                            return((TField)(object)DateTime.MinValue);
                        }
                        if (currentDate == currentService.DateMaxValue)
                        {
                            // This field contains the maximum date value of the current database.
                            // We convert it to .NET's maximum date value
                            return((TField)(object)DateTime.MaxValue);
                        }
                        return((TField)dataRow[fieldName]);
                    }

                    return((TField)dataRow[fieldName]);
                }

                return((TField)dataRow[fieldName]);
            }
            catch
            {
                return(default);
 /// <summary>
 /// Creates the specified entity.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <returns></returns>
 public override Guid Create(BusinessEntity entity)
 {
     Assert.ArgumentNotNull(entity, "entity");
     return(CrmRemoteSettings.CrmService.Create(entity));
 }
Ejemplo n.º 35
0
        public UserSetting(string title, string firstName, string lastName, string middleName, BusinessEntity businessEntity, ApplicationUser user)
        {
            this.CreateDate     = System.DateTime.UtcNow;
            this.ModifiedDate   = System.DateTime.UtcNow;
            this.rowguid        = Guid.NewGuid();
            this.FirstName      = firstName;
            this.LastName       = lastName;
            this.MiddleName     = middleName;
            this.BusinessEntity = businessEntity;
            // this.ApplicationUser = user;

            this.Task      = new HashSet <Task>();
            this.Deal      = new HashSet <Deal>();
            this.Note      = new HashSet <Note>();
            this.File      = new HashSet <File>();
            this.Pipeline  = new HashSet <Pipeline>();
            this.DealUser  = new HashSet <DealUser>();
            this.StageUser = new HashSet <StageUser>();
            this.Goal      = new HashSet <Goal>();
            this.DealStage = new HashSet <DealStage>();
        }
Ejemplo n.º 36
0
 public void DeleteBusinessEntity(BusinessEntity be)
 {
     be.Delete();
 }
Ejemplo n.º 37
0
        public static BaseEntity Clone(BaseEntity SourceObj)
        {
            TableDef       td      = GetTableDef(SourceObj.GetType());
            BusinessEntity DestObj = (BusinessEntity)BaseFactory
                                     .CreateInstance(td._ClassType);
            IRuleInitUI px = DestObj as IRuleInitUI;

            //CallLoadRule = CallLoadRule && px != null;

            DestObj.EntityOnLoad = true;
            try
            {
                foreach (FieldDef fd in td.KeyFields.Values)
                {
                    fd.SetLoadValue(DestObj, fd.GetValue(SourceObj));
                }
                foreach (FieldDef fd in td.NonKeyFields.Values)
                {
                    fd.SetLoadValue(DestObj, fd.GetValue(SourceObj));
                }

                if (td.ChildEntities.Count > 0)
                {
                    foreach (EntityCollDef ecd in td.ChildEntities)
                    {
                        IList SrcCols  = ecd.GetValue(SourceObj);
                        IList DestCols = ecd.GetValue(DestObj);
                        int   NumDest  = DestCols.Count;
                        ((IEntityCollection)DestCols).OnLoad = true;
                        int i = 0;
                        foreach (BaseEntity obj in SrcCols)
                        {
                            if (i < NumDest)
                            {
                                Clone((BaseEntity)DestCols[i++], obj);
                            }
                            else
                            {
                                DestCols.Add(Clone(obj));
                            }
                        }
                        ((IEntityCollection)DestCols).OnLoad = false;
                    }
                }

                //if (CallLoadRule)
                //{
                //px.AfterLoadFound();
                //BaseFramework.DoEntityAction(DestObj, enEntityActionMode.AfterLoadFound);
                //}
                BusinessEntity be = DestObj as BusinessEntity;
                if (be != null)
                {
                    be.AfterClone((BusinessEntity)SourceObj);
                }
            }
            finally
            {
                DestObj.EntityOnLoad = false;
                DestObj.DataChanged();
            }
            return(DestObj);
        }
Ejemplo n.º 38
0
 public void InsertBusinessEntity(BusinessEntity be)
 {
     be.Insert();
 }
Ejemplo n.º 39
0
 public WhereClause(BusinessEntity entity)
 {
     this._entity = entity;
 }
Ejemplo n.º 40
0
 public void Update( BusinessEntity entity )
 {
     m_service.Update( entity );
 }
 /// <summary>
 /// Updates the specified entity.
 /// </summary>
 /// <param name="entity">The entity.</param>
 public override void Update(BusinessEntity entity)
 {
     Assert.ArgumentNotNull(entity, "entity");
     CrmRemoteSettings.CrmService.Update(entity);
 }
Ejemplo n.º 42
0
 public SqlClientDynamicQuery(BusinessEntity entity)
     : base(entity)
 {
 }
Ejemplo n.º 43
0
 public void UpdateBusinessEntity(BusinessEntity be)
 {
     be.Update();
 }
Ejemplo n.º 44
0
 public MySql4DynamicQuery(BusinessEntity entity)
     : base(entity)
 {
 }
Ejemplo n.º 45
0
 public Guid Create( BusinessEntity entity )
 {
     return m_service.Create( entity );
 }
Ejemplo n.º 46
0
		public void PythonRulesIsValid( )
		{
			IRulesFactory<BusinessEntity> factory = new PythonRulesFactory<BusinessEntity>( );

			factory.AddRule( 
				RuleType.Persistence, 
				"def validate(e): return e.Value > 5", 
				"Value must be greater than 5.",
				"Value" );
			factory.AddRule( 
				RuleType.Business, 
				"def validate(e): return e.Value2 > 5", 
				"Value2 must be greater than 5.", 
				"Value2" );

			var businessEntity = new BusinessEntity( );
			businessEntity.PersistenceRules.Add( factory.FindRules( RuleType.Persistence ) );
			businessEntity.BusinessRules.Add( factory.FindRules( RuleType.Business ) );

			businessEntity.Value = 6;
			businessEntity.Value2 = 1;

			Assert.IsTrue( businessEntity.IsPersistable( ) );
			Assert.IsFalse( businessEntity.IsValid( ) );
		}
Ejemplo n.º 47
0
        /// <summary>
        ///   Publica serviciul cu informatiile specificate in campurile corespunzatoare (daca nu exista deja).
        /// </summary>
        public void performPublish()
        {
            String businessName = txbBusinessName.Text.Trim();
            String serviceName  = txbServiceName.Text.Trim();
            String accessPoint  = txbAccessPoint.Text.Trim();

            if (businessName == String.Empty || serviceName == String.Empty || accessPoint == String.Empty) {

                MessageBox.Show("All values must be set", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try {

                FindBusiness findBusiness = new FindBusiness(businessName);

                findBusiness.FindQualifiers.Add(FindQualifier.ExactNameMatch);

                BusinessList businessList = findBusiness.Send(uddiConnection);

                if (0 == businessList.BusinessInfos.Count) {

                    BusinessEntity newBusinessEntity   = new BusinessEntity(businessName);

                    BusinessService newBusinessService = new BusinessService(serviceName);

                    newBusinessEntity.BusinessServices.Add(newBusinessService);

                    BindingTemplate newBindingTemplate = new BindingTemplate();

                    newBindingTemplate.AccessPoint.Text    = accessPoint;
                    newBindingTemplate.AccessPoint.UrlType = UrlType.Http;

                    selectOntologyForNewBindingTemplate(newBindingTemplate);

                    newBusinessService.BindingTemplates.Add(newBindingTemplate);

                    SaveBusiness saveNewBusiness = new SaveBusiness(newBusinessEntity);

                    saveNewBusiness.Send(uddiConnection);
                }
                else {

                    MessageBox.Show("Business already exists");

                    GetBusinessDetail getBusinessDetail = new GetBusinessDetail(businessList.BusinessInfos[0].BusinessKey);

                    BusinessDetail businessDetail    = getBusinessDetail.Send(uddiConnection);

                    BusinessEntity oldBusinessEntity = businessDetail.BusinessEntities[0];

                    FindService findService = new FindService(serviceName);

                    findService.FindQualifiers.Add(FindQualifier.ExactNameMatch);

                    findService.BusinessKey = businessDetail.BusinessEntities[0].BusinessKey;

                    ServiceList serviceList = findService.Send(uddiConnection);

                    if (0 == serviceList.ServiceInfos.Count) {

                        BusinessService newBusinessService     = new BusinessService(serviceName);

                        oldBusinessEntity.BusinessServices.Add(newBusinessService);

                        BindingTemplate newBindingTemplate     = new BindingTemplate();

                        newBindingTemplate.AccessPoint.Text    = accessPoint;
                        newBindingTemplate.AccessPoint.UrlType = UrlType.Http;

                        selectOntologyForNewBindingTemplate(newBindingTemplate);

                        newBusinessService.BindingTemplates.Add(newBindingTemplate);

                        SaveBusiness saveOldBusiness = new SaveBusiness(oldBusinessEntity);

                        saveOldBusiness.Send(uddiConnection);
                    }
                    else {

                        MessageBox.Show("Service already exists");

                        GetServiceDetail getServiceDetail  = new GetServiceDetail(serviceList.ServiceInfos[0].ServiceKey);

                        ServiceDetail serviceDetail        = getServiceDetail.Send(uddiConnection);

                        BusinessService oldBusinessService = serviceDetail.BusinessServices[0];

                        foreach (BindingTemplate bindingTemplate in oldBusinessService.BindingTemplates) {

                            if (bindingTemplate.AccessPoint.Text == accessPoint) {

                                MessageBox.Show("Binding already exists");
                                return;
                            }
                        }

                        BindingTemplate newBindingTemplate     = new BindingTemplate();

                        newBindingTemplate.AccessPoint.Text    = accessPoint;
                        newBindingTemplate.AccessPoint.UrlType = UrlType.Http;

                        selectOntologyForNewBindingTemplate(newBindingTemplate);

                        oldBusinessService.BindingTemplates.Add(newBindingTemplate);

                        SaveService saveOldService = new SaveService(oldBusinessService);

                        saveOldService.Send(uddiConnection);
                    }
                }

                MessageBox.Show("Publish successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (UddiException e) {

                MessageBox.Show("Uddi error: "+ e.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception e){

                MessageBox.Show("General exception: " + e.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 48
0
 public override void Update(BusinessEntity updateFrom)
 {
     throw new NotImplementedException();
 }