Beispiel #1
0
        //----------------------------------------------------------------------------------------------------------
        public static void AddProfilePageDetails(UsersDataEntity usersDataObject)
        {
            ItemsEntity page = new ItemsEntity();

            page.ModuleTypeID = (int)ModuleTypes.UsersProfiles;
            page.OwnerID      = usersDataObject.UserId;
            //-----------------------------------------------------
            //AddDetails
            //----------------------------
            ItemsDetailsEntity itemDetailsObject;

            if (SiteSettings.Languages_HasArabicLanguages)
            {
                itemDetailsObject        = new ItemsDetailsEntity();
                itemDetailsObject.LangID = Languages.Ar;

                itemDetailsObject.Title = DynamicResource.GetText("Modules", "PageTitle_UserProfilePage");
                itemDetailsObject.ExtraData.Add("");
                page.Details[Languages.Ar] = itemDetailsObject;
            }
            if (SiteSettings.Languages_HasEnglishLanguages)
            {
                itemDetailsObject        = new ItemsDetailsEntity();
                itemDetailsObject.LangID = Languages.En;
                itemDetailsObject.Title  = DynamicResource.GetText("Modules", "PageTitle_UserProfilePage");
                itemDetailsObject.ExtraData.Add("");
                page.Details[Languages.En] = itemDetailsObject;
            }
            //-----------------------------------------------------
            ItemsModulesOptions UsersProfilesModule = ItemsModulesOptions.GetType((int)ModuleTypes.UsersProfiles);

            ItemsFactory.Create(page, UsersProfilesModule);
            //-----------------------------------------------------
            usersDataObject.ProfilePageID = page.ItemID;
        }
Beispiel #2
0
 //----------------------------------------------------------
 public void AddItems(ItemsModulesOptions itemsModule, int categoryID)
 {
     //-------------------------------------------------------------
     InitialItem.CategoryID   = categoryID;
     InitialItem.ModuleTypeID = itemsModule.ModuleTypeID;
     //-------------------------------------------------------------
     for (int i = 0; i < 15; i++)
     {
         if (SiteSettings.Languages_HasArabicLanguages)
         {
             InitialItem.Details[Languages.Ar] = InitialItemArDetails;
         }
         if (SiteSettings.Languages_HasEnglishLanguages)
         {
             InitialItem.Details[Languages.En] = InitialItemEnDetails;
         }
         ExecuteCommandStatus status = ItemsFactory.Create(InitialItem, itemsModule);
         if (status == ExecuteCommandStatus.Done)
         {
             if (itemsModule.HasComments)
             {
                 AddComments(itemsModule.ModuleTypeID, InitialItem.ItemID, ModuleBaseTypes.Items);
             }
         }
     }
 }
Beispiel #3
0
        //----------------------------------------------------------------------------------------------------------
        public static int AddSubSitePageDetails(int PageNo, UsersDataEntity usersDataObject)
        {
            ItemsEntity page = new ItemsEntity();

            page.ModuleTypeID = (int)ModuleTypes.SubSitePages;
            page.OwnerID      = usersDataObject.UserId;
            //-----------------------------------------------------
            //AddDetails
            //----------------------------
            ItemsDetailsEntity itemDetailsObject;

            if (SiteSettings.Languages_HasArabicLanguages)
            {
                itemDetailsObject        = new ItemsDetailsEntity();
                itemDetailsObject.LangID = Languages.Ar;
                itemDetailsObject.Title  = DynamicResource.GetText("SubSites", "Page_" + PageNo);
                itemDetailsObject.ExtraData.Add("");
                page.Details[Languages.Ar] = itemDetailsObject;
            }
            if (SiteSettings.Languages_HasEnglishLanguages)
            {
                itemDetailsObject        = new ItemsDetailsEntity();
                itemDetailsObject.LangID = Languages.En;
                itemDetailsObject.Title  = DynamicResource.GetText("SubSites", "Page_" + PageNo);
                itemDetailsObject.ExtraData.Add("");
                page.Details[Languages.En] = itemDetailsObject;
            }
            //-----------------------------------------------------
            ItemsModulesOptions subSitePagesModule = ItemsModulesOptions.GetType((int)ModuleTypes.SubSitePages);

            ItemsFactory.Create(page, subSitePagesModule);
            //-----------------------------------------------------
            return(page.ItemID);
        }
        public void WeaponsFactoryCreateRandomWeapon()
        {
            ItemsFactory factory         = new ItemsFactory();
            var          creationProfile = new ItemProfile(1, EntityOccupation.Warrior);
            IItem        item1           = factory.Create(creationProfile);

            Assert.IsNotNull(item1);
            Assert.AreEqual(item1.Quality, item1.Quality);
        }
        public void WeaponsFactoryCreateSpecifiedWeapon()
        {
            ItemsFactory factory         = new ItemsFactory();
            var          creationProfile = new ItemProfile(1, ItemType.Crossbow, ItemQualityCode.Flawless);
            IItem        item1           = factory.Create(creationProfile);

            Assert.IsNotNull(item1);
            Assert.AreEqual(creationProfile.qualityCode, item1.Quality);
            Assert.AreEqual(creationProfile.Type, item1.Info.TypeCode);
        }
 public void AddOccupation(IEntity entity, EntityOccupation occupation)
 {
     if (this.inventoryItemProfiles.Keys.Contains(occupation))
     {
         // get the item profile
         var itemProfileArray = this.inventoryItemProfiles[occupation].NextWithReplacement();
         for (int i = 0; i < itemProfileArray.Length; i++)
         {
             IItem item = weaponFactory.Create(new ItemProfile(1, occupation, itemProfileArray[i]));
             if (item != null)
             {
                 entity.Inventory.Set(item, InventorySlot.Any, entity.Stats);
             }
         }
     }
 }
Beispiel #7
0
    //-----------------------------------------------
    #endregion

    #region ---------------btnSave_Click---------------
    //-----------------------------------------------
    //btnSave_Click
    //-----------------------------------------------
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid || (currentModule.HasItemDate && !ucItemDate.IsValid) || (currentModule.HasItemEndDate && !ucItemEndDate.IsValid))
        {
            return;
        }
        //--------------------------------------------------
        ItemsEntity itemsObject = new ItemsEntity();

        //--------------------------------------------------
        #region Item Files properties

        // uploaded files extenssions
        string uploadedPhotoExtension  = Path.GetExtension(fuPhoto.FileName);
        string uploadedFileExtension   = Path.GetExtension(fuFile.FileName);
        string uploadedVideoExtension  = Path.GetExtension(fuVideo.FileName);
        string uploadedAudioExtension  = Path.GetExtension(fuAudio.FileName);
        string uploadedPhoto2Extension = Path.GetExtension(fuPhoto2.FileName);
        //---------------------------------------------------------------------
        #region Uploaded Files checks
        #region Uploaded photo file checks
        if (fuPhoto.HasFile)
        {
            if (!MoversFW.Photos.CheckIsImage(fuPhoto.PostedFile))
            {
                lblResult.CssClass = "lblResult_Faild";
                lblResult.Text     = Resources.AdminText.InvalidPhotoFile;
                return;
            }

            /*
             * //Check suported extention
             * if (!SiteSettings.CheckUploadedFileExtension(uploadedPhotoExtension, currentModule.PhotoAvailableExtension))
             * {
             *  lblResult.CssClass = "lblResult_Faild";
             *  lblResult.Text = Resources.AdminText.NotSuportedFileExtention + currentModule.PhotoAvailableExtension;
             *  return;
             * }*/
            //Check max length
            if (!SiteSettings.CheckUploadedFileLength(fuPhoto.PostedFile.ContentLength, currentModule.PhotoMaxSize))
            {
                lblResult.CssClass = "lblResult_Faild";
                lblResult.Text     = Resources.AdminText.UploadedFileGreaterThanMaxLength + currentModule.PhotoMaxSize;
                return;
            }
            //--------------------------------------------------------------------
        }
        #endregion
        #region Uploaded file checks
        //File
        if (fuFile.HasFile)
        {/*
          * //Check suported extention
          * if (!SiteSettings.CheckUploadedFileExtension(uploadedFileExtension, currentModule.FileAvailableExtension))
          * {
          *     lblResult.CssClass = "lblResult_Faild";
          *     lblResult.Text = Resources.AdminText.NotSuportedFileExtention + currentModule.FileAvailableExtension;
          *     return;
          * }*/
            //Check max length
            if (!SiteSettings.CheckUploadedFileLength(fuFile.PostedFile.ContentLength, currentModule.FileMaxSize))
            {
                lblResult.CssClass = "lblResult_Faild";
                lblResult.Text     = Resources.AdminText.UploadedFileGreaterThanMaxLength + currentModule.FileMaxSize;
                return;
            }
        }
        //-----------------------------------------------------------------
        #endregion
        #region Uploaded video file checks
        //Video
        if (fuVideo.HasFile)
        {/*
          * //Check suported extention
          * if (!SiteSettings.CheckUploadedFileExtension(uploadedVideoExtension, currentModule.VideoAvailableExtension))
          * {
          *     lblResult.CssClass = "lblResult_Faild";
          *     lblResult.Text = Resources.AdminText.NotSuportedVideoExtention + currentModule.VideoAvailableExtension;
          *     return;
          * }*/
            //Check max length
            if (!SiteSettings.CheckUploadedFileLength(fuVideo.PostedFile.ContentLength, currentModule.VideoMaxSize))
            {
                lblResult.CssClass = "lblResult_Faild";
                lblResult.Text     = Resources.AdminText.UploadedVideoGreaterThanMaxLength + currentModule.VideoMaxSize;
                return;
            }
        }
        //-----------------------------------------------------------------
        #endregion
        #region Uploaded audio file checks
        //Audio
        if (fuAudio.HasFile)
        {/*
          * //Check suported extention
          * if (!SiteSettings.CheckUploadedFileExtension(uploadedAudioExtension, currentModule.AudioAvailableExtension))
          * {
          *     lblResult.CssClass = "lblResult_Faild";
          *     lblResult.Text = Resources.AdminText.NotSuportedAudioExtention + currentModule.VideoAvailableExtension;
          *     return;
          * }*/
            //Check max length
            if (!SiteSettings.CheckUploadedFileLength(fuAudio.PostedFile.ContentLength, currentModule.AudioMaxSize))
            {
                lblResult.CssClass = "lblResult_Faild";
                lblResult.Text     = Resources.AdminText.UploadedAudioGreaterThanMaxLength + currentModule.AudioMaxSize;
                return;
            }
        }
        //-----------------------------------------------------------------
        #endregion
        #region Uploaded photo2 file checks
        //-----------------------------------------------------------------
        //Photo2
        if (fuPhoto2.HasFile)
        {
            if (!MoversFW.Photos.CheckIsImage(fuPhoto2.PostedFile))
            {
                lblResult.CssClass = "lblResult_Faild";
                lblResult.Text     = Resources.AdminText.InvalidPhotoFile;
                return;
            }/*
              * //Check suported extention
              * if (!SiteSettings.CheckUploadedFileExtension(uploadedPhoto2Extension, currentModule.Photo2AvailableExtension))
              * {
              * lblResult.CssClass = "lblResult_Faild";
              * lblResult.Text = Resources.AdminText.NotSuportedFileExtention + currentModule.Photo2AvailableExtension;
              * return;
              * }*/
            //Check max length
            if (!SiteSettings.CheckUploadedFileLength(fuPhoto2.PostedFile.ContentLength, currentModule.Photo2MaxSize))
            {
                lblResult.CssClass = "lblResult_Faild";
                lblResult.Text     = Resources.AdminText.UploadedFileGreaterThanMaxLength + currentModule.Photo2MaxSize;
                return;
            }
            //--------------------------------------------------------------------
        }
        //-----------------------------------------------------------------
        #endregion
        #endregion



        #region Set properties
        //items files
        itemsObject.PhotoExtension  = uploadedPhotoExtension;
        itemsObject.FileExtension   = uploadedFileExtension;
        itemsObject.VideoExtension  = uploadedVideoExtension;
        itemsObject.AudioExtension  = uploadedAudioExtension;
        itemsObject.Photo2Extension = uploadedPhoto2Extension;
        //------------------------------------------------------
        #endregion
        #endregion

        //itemsObject.Title = txtTitle.Text;
        if (trCategoryID.Visible)
        {
            itemsObject.CategoryID = Convert.ToInt32(ddlItemCategories.SelectedValue);
        }
        //itemsObject.ShortDescription = txtShortDescription.Text;
        //itemsObject.Description = txtDetails.Value;
        itemsObject.Email = txtEmail.Text;

        // itemsObject.AuthorName = txtAuthorName.Text;
        if (currentModule.HasPriority && Sender == UsersTypes.Admin)
        {
            itemsObject.Priority = Convert.ToInt32(ddlPriority.SelectedValue);
        }
        itemsObject.Url = txtUrl.Text;
        if (currentModule.HasHeight)
        {
            itemsObject.Height = Convert.ToInt32(txtHeight.Text);
        }
        if (currentModule.HasWidth)
        {
            itemsObject.Width = Convert.ToInt32(txtWidth.Text);
        }
        //if (currentModule.HasItemDate && !string.IsNullOrEmpty(txtItemDate.Text)) itemsObject.ItemDate = Convert.ToDateTime(txtItemDate.Text);
        if (currentModule.HasItemDate && ucItemDate.Date != DateTime.MinValue)
        {
            itemsObject.ItemDate = ucItemDate.Date;
        }
        //-----------------------------------
        //ItemEndDate
        //if (currentModule.HasItemEndDate && !string.IsNullOrEmpty(txtItemEndDate.Text)) itemsObject.ItemEndDate = Convert.ToDateTime(txtItemEndDate.Text);
        if (currentModule.HasItemEndDate && ucItemEndDate.Date != DateTime.MinValue)
        {
            itemsObject.ItemEndDate = ucItemEndDate.Date;
        }

        //itemsObject.Address = txtAddress.Text;
        itemsObject.MailBox = txtMailBox.Text;
        itemsObject.ZipCode = txtZipCode.Text;
        itemsObject.Tels    = txtTels.Text;
        itemsObject.Fax     = txtFax.Text;
        itemsObject.Mobile  = txtMobile.Text;
        //-------------------------------------------------------------------------------------------
        itemsObject.IsMain        = CbIsMain.Checked;
        itemsObject.SpecialOption = cbSpecialOption.Checked;
        itemsObject.ModuleTypeID  = ModuleTypeID;
        //-----------------------------------
        itemsObject.YoutubeCode = txtYoutubeCode.Text;
        //---------------------------------------------------------------------------------------------------------
        if (currentModule.HasGoogleLatitude)
        {
            itemsObject.GoogleLatitude = Convert.ToDouble(txtGoogleLatitude.Text);
        }
        //---------------------------------------------------------------------------------------------------------
        if (currentModule.HasGoogleLongitude)
        {
            itemsObject.GoogleLongitude = Convert.ToDouble(txtGoogleLongitude.Text);
        }
        //---------------------------------------------------------------------------------------------------------
        itemsObject.Price            = txtPrice.Text;
        itemsObject.OnlyForRegisered = cbOnlyForRegisered.Checked;
        //---------------------------------------------------------------------------------------------------------
        //Files publishing
        itemsObject.PublishPhoto  = cbPublishPhoto.Checked;
        itemsObject.PublishPhoto2 = cbPublishPhoto2.Checked;
        itemsObject.PublishFile   = cbPublishFile.Checked;
        itemsObject.PublishAudio  = cbPublishAudio.Checked;
        itemsObject.PublishVideo  = cbPublishVideo.Checked;
        itemsObject.PublishYoutbe = cbPublishYoutbe.Checked;
        //---------------------------------------------------------------------------------------------------------
        if (currentModule.HasAuthorID)
        {
            int authorID = Convert.ToInt32(ddlAuthorID.SelectedValue);
            itemsObject.AuthorID = authorID;
            if (authorID > 0)
            {
                itemsObject.AuthorName = ddlAuthorID.SelectedItem.Text;
                selectedAuthor         = ItemsFactory.GetObject(authorID, Languages.Unknowen, UsersTypes.Admin, OwnerID);
            }
        }
        //-------------------------------------------------------------------------------------------
        //Check is  available
        // logic of is available "if the module hasn't IsAvailable -> then  All items ara vailable "
        if (currentModule.HasIsAvailable && Sender == UsersTypes.Admin)
        {
            itemsObject.IsAvailable = cbIsAvailable.Checked;
        }
        else if (Sender == UsersTypes.User)
        {
            itemsObject.IsAvailable = false;
        }
        else
        {
            itemsObject.IsAvailable = true;
        }
        //-------------------------------------------------------------------------------------------
        itemsObject.Icon = txtIconControl.Text;

        //-----------------------------------------------
        //Visitors Participations
        //----------------------------
        if (Sender == UsersTypes.User || Sender == UsersTypes.SuperUser)
        {
            //----------------------------------------------------------------------------------------
            if (this.Page.User != null && this.Page.User.Identity.IsAuthenticated && !UsersDataFactory.IsCurrentUserTheAdmin())
            {
                MembershipUser user   = Membership.GetUser(this.Page.User.Identity.Name);
                Guid           userID = new Guid(user.ProviderUserKey.ToString());
                itemsObject.UserId = userID;
                UsersDataEntity userData = UsersDataFactory.GetUsersDataObject(userID, OwnerID);
                itemsObject.SenderName  = userData.Name;
                itemsObject.SenderEMail = user.Email;
            }
            else
            {
                itemsObject.SenderName  = txtSenderName.Text;
                itemsObject.SenderEMail = txtSenderEMail.Text;
            }
            //----------------------------------------------------------------------------------------
            //HasSenderCountryID
            if (currentModule.HasSenderCountryID)
            {
                itemsObject.SenderCountryID = Convert.ToInt32(ddlSenderCountry.SelectedValue);
            }
            //----------------------------------------------------------------------------------------
            itemsObject.IsVisitorsParticipations = true;
        }
        //----------------------------------------------------------------------------------------
        if (OwnerID != null)
        {
            itemsObject.OwnerID = (Guid)OwnerID;
        }
        //-------------------------------------------------------------------------------------------
        if (currentModule.HasType)
        {
            itemsObject.Type = Convert.ToInt32(ddlType.SelectedValue);
        }
        //-------------------------------------------------------------------------------------------

        //Details -----------------------
        AddDetails(itemsObject);
        //----------------------------------------------------------------------------------------
        if (itemsObject.Details.Count == 0)
        {
            if (SiteSettings.Languages_HasArabicLanguages)
            {
                ItemsDetailsEntity arabicDetails = new ItemsDetailsEntity();
                arabicDetails.LangID = Languages.Ar;
                itemsObject.Details[Languages.Ar] = arabicDetails;
            }
            if (SiteSettings.Languages_HasEnglishLanguages)
            {
                ItemsDetailsEntity englishDetails = new ItemsDetailsEntity();
                englishDetails.LangID             = Languages.En;
                itemsObject.Details[Languages.En] = englishDetails;
            }
        }
        //----------------------------------------------------------------------------------------

        //ItemsDetailsEntity d = itemsObject.Details[Languages.Ar];
        //if(selectedAuthor!=n)
        //-------------------------------
        ExecuteCommandStatus status = ItemsFactory.Create(itemsObject, currentModule);
        if (status == ExecuteCommandStatus.Done)
        {
            SaveFiles(itemsObject);
            //------------------------------------------------------------------------
            //RegisterInMailList
            if (currentModule.MailListAutomaticRegistration && !string.IsNullOrEmpty(itemsObject.Email))
            {
                ItemsFactory.RegisterInMailList(itemsObject);
            }
            //------------------------------------------------------------------------
            //RegisterInSms
            if (currentModule.SmsAutomaticRegistration && !string.IsNullOrEmpty(itemsObject.Mobile))
            {
                ItemsFactory.RegisterInSms(itemsObject);
            }
            //------------------------------------------------------------------------
            lblResult.CssClass = "lblResult_Done";
            lblResult.Text     = Resources.AdminText.AddingOperationDone;
            ClearControls();
        }
        else if (status == ExecuteCommandStatus.AllreadyExists)
        {
            lblResult.CssClass = "lblResult_Faild";
            lblResult.Text     = Resources.AdminText.DuplicateItem;
        }
        else
        {
            lblResult.CssClass = "lblResult_Faild";
            lblResult.Text     = Resources.AdminText.AddingOperationFaild;
        }
    }