예제 #1
0
        /// <summary>
        /// Add a new component to a Plugg
        /// Existing PluggComponents must be in p.TheComponents
        /// newComponentData is of type PHText, PHLatex or YouTube
        /// newComponent must have ComponentOrder and ComponentType set
        /// </summary>
        /// <param name="p"></param>
        /// <param name="newComponent"></param>
        /// <param name="newComponentData"></param>
        public void AddComponent(PluggContainer p, PluggComponent newComponent, object newComponentData = null)
        {
            List <PluggComponent> cmps = p.GetComponentList();

            if (newComponent.ComponentOrder < 1 || newComponent.ComponentOrder > cmps.Count + 1)
            {
                throw new Exception("ComponentOrder is out of range");
            }
            if (newComponent.ComponentType == EComponentType.NotSet)
            {
                throw new Exception("You must set ComponentType");
            }

            PluggComponent pcToUpdate;

            for (int order = newComponent.ComponentOrder; order <= cmps.Count; order++)
            {
                pcToUpdate = rep.GetPluggComponent(cmps[order - 1].PluggComponentId);
                pcToUpdate.ComponentOrder += 1;
                rep.UpdatePluggComponent(pcToUpdate);
            }

            newComponent.PluggId = p.ThePlugg.PluggId;
            rep.CreatePluggComponent(newComponent);
        }
예제 #2
0
 public void CreatePluggComponent(PluggComponent t)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository <PluggComponent>();
         rep.Insert(t);
     }
 }
예제 #3
0
 public void CreatePluggComponent(PluggComponent t)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository<PluggComponent>();
         rep.Insert(t);
     }
 }
예제 #4
0
 public void UpdatePluggComponent(PluggComponent pc)
 {
     using (IDataContext db = DataContext.Instance())
     {
         var rep = db.GetRepository <PluggComponent>();
         rep.Update(pc);
     }
 }
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     BaseHandler plugghandler = new BaseHandler();
     PluggComponent pc = new PluggComponent();
     pc.ComponentOrder = Order + 1;
     pc.ComponentType = (EComponentType)Enum.Parse(typeof(EComponentType), ddCoponentList.SelectedValue);
     plugghandler.AddComponent(this.PluggContainer, pc);
     //Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(this.TabID, "", new string[] { "edit=1", "language=" + this.CurrentLanguage }));
 }
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     PluggContainer pc = new PluggContainer("en-us", PluggId);
     pc.GetComponentList();
     PluggComponent cmp = new PluggComponent();
     cmp.ComponentOrder = ComponentOrder;
     cmp.ComponentType = (EComponentType)(ddNewComponent.SelectedIndex+1);
     cmp.PluggId = PluggId;
     BaseHandler bh = new BaseHandler();
     bh.AddComponent(pc, cmp);
     Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", "edit=0"));
 }
예제 #7
0
        /// <summary>
        /// Deletes the PluggComponent at position "delOrder".
        /// Existing PluggComponents must be in p.TheComponents
        /// Deletes ComponenData as well if exist
        /// </summary>
        /// <param name="p"></param>
        /// <param name="order"></param>
        public void DeleteComponent(PluggContainer p, int delOrder)
        {
            List <PluggComponent> cmps = p.GetComponentList();

            if (delOrder < 1 || delOrder > cmps.Count)
            {
                throw new Exception("order is out of range");
            }

            PluggComponent pcToDelete = cmps[delOrder - 1];

            if (pcToDelete.PluggComponentId != 0)
            {
                switch (pcToDelete.ComponentType)
                {
                case EComponentType.Label:
                    rep.DeleteAllPhTextForItem(pcToDelete.PluggComponentId, ETextItemType.PluggComponentLabel);
                    break;

                case EComponentType.RichText:
                    rep.DeleteAllPhTextForItem(pcToDelete.PluggComponentId, ETextItemType.PluggComponentRichText);
                    break;

                case EComponentType.RichRichText:
                    rep.DeleteAllPhTextForItem(pcToDelete.PluggComponentId, ETextItemType.PluggComponentRichRichText);
                    break;

                case EComponentType.Latex:
                    rep.DeleteAllLatexForItem(pcToDelete.PluggComponentId, ELatexItemType.PluggComponentLatex);
                    break;

                case EComponentType.YouTube:
                    rep.DeleteYouTube(new YouTube()
                    {
                        YouTubeId = pcToDelete.PluggComponentId
                    });
                    break;
                }
            }

            rep.DeletePluggComponent(pcToDelete);

            PluggComponent pcToUpdate;

            for (int order = delOrder + 1; order <= cmps.Count; order++)
            {
                pcToUpdate = rep.GetPluggComponent(cmps[order - 1].PluggComponentId);
                pcToUpdate.ComponentOrder -= 1;
                rep.UpdatePluggComponent(pcToUpdate);
            }
        }
예제 #8
0
        /// <summary>
        /// Add a new component to a Plugg
        /// Existing PluggComponents must be in p.TheComponents
        /// newComponentData is of type PHText, PHLatex or YouTube
        /// newComponent must have ComponentOrder and ComponentType set
        /// </summary>
        /// <param name="p"></param>
        /// <param name="newComponent"></param>
        /// <param name="newComponentData"></param>
        public void AddComponent(PluggContainer p, PluggComponent newComponent, object newComponentData = null)
        {
            List<PluggComponent> cmps = p.GetComponentList();
            if (newComponent.ComponentOrder < 1 || newComponent.ComponentOrder > cmps.Count + 1)
                throw new Exception("ComponentOrder is out of range");
            if (newComponent.ComponentType == EComponentType.NotSet)
                throw new Exception("You must set ComponentType");

            PluggComponent pcToUpdate;
            for (int order = newComponent.ComponentOrder; order <= cmps.Count; order++ )
            {
                pcToUpdate = rep.GetPluggComponent(cmps[order-1].PluggComponentId);
                pcToUpdate.ComponentOrder += 1;
                rep.UpdatePluggComponent(pcToUpdate);
            }

            newComponent.PluggId = p.ThePlugg.PluggId;
            rep.CreatePluggComponent(newComponent);
        }
예제 #9
0
        private void CallLatFun(int ltorderid, PluggComponent comp, PHLatex lat, string p)
        {
            hdnlabel.Value = Convert.ToString(comp.PluggComponentId);

            if (comp.ComponentType == EComponentType.Latex)
            {
                pnlRRT.Visible = true;
                pnllabel.Visible = false;
                pnlletex.Visible = false;
                richtextbox.Visible = false;

                pnlYoutube.Visible = false;
                richrichtext.Text = lat.Text;
            }
            pnlPluggCom.Visible = false;
        }
예제 #10
0
        private void LoadControl(int IntCompOrder, bool isLastComp, PluggComponent comp)
        {
            ControlViewModel viewModel = new ControlViewModel();
            viewModel.ComponentType = comp.ComponentType;
            viewModel.ComponentID = comp != null ? comp.PluggComponentId : 0;
            viewModel.UserID = this.UserId;
            viewModel.Order = IntCompOrder;
            viewModel.TabID = TabId;
            viewModel.isLastComp = isLastComp;
            viewModel._this = this;

            Control_Case _control = new Control_Case(this._Case);
            _control.RunComponentType(comp.ComponentType, viewModel);
        }
예제 #11
0
        private void YouTubeEdit(int ytorderid, PluggComponent comp, YouTube yt)
        {
            string ytcode = "";
            if (yt == null)
                ytcode = "";
            else
                ytcode = yt.YouTubeCode;
            hdnlabel.Value = Convert.ToString(comp.PluggComponentId);

            if (comp.ComponentType == EComponentType.YouTube)
            {

                pnlYoutube.Visible = true;
                pnlRRT.Visible = false;
                pnllabel.Visible = false;
                pnlletex.Visible = false;
                richtextbox.Visible = false;
                txtYouTube.Text = ytcode;
            }
            pnlPluggCom.Visible = false;
        }
예제 #12
0
        private void ImpGoogleTrans(PluggComponent comp, PHText CulTxt)
        {
            hdnlabel.Value = Convert.ToString(comp.PluggComponentId);

            string text = CulTxt.Text;
            switch (comp.ComponentType)
            {
                case EComponentType.Label:
                    CompHide();
                    txtlabel.Text = text;
                    pnllabel.Visible = true;
                    break;

                case EComponentType.RichText:
                    CompHide();
                    richtextbox.Visible = true;
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", " $(document).ready(function () {$('#editor').html('" + text.Replace("\r\n", "<br />") + "')});", true);
                    break;

                case EComponentType.RichRichText:
                    CompHide();
                    pnlRRT.Visible = true;
                    richrichtext.Text = text;
                    break;
            }
            pnlPluggCom.Visible = false;
        }
예제 #13
0
        private void LoadRichRich(PluggComponent c, int controlOrder)
        {
            RichRichControl ucRR = (RichRichControl)this.LoadControl("/DesktopModules/PlugghestControls/RichRichControl.ascx");
            if ((ucRR != null))
            {
                ucRR.ModuleConfiguration = this.ModuleConfiguration;
                ucRR.ItemId = c.PluggComponentId;
                ucRR.CultureCode = CultureCode;
                ucRR.CreatedInCultureCode = pc.ThePlugg.CreatedInCultureCode;
                ucRR.ControlOrder = controlOrder;
                ucRR.ItemType = ETextItemType.PluggComponentRichRichText;
                ucRR.Case = EControlCase.View;
                if (InCreationLanguage && IsAuthorized && Edit > -1)
                    ucRR.Case = EControlCase.ViewAllowEdit;
                if (InCreationLanguage && IsAuthorized && Edit == controlOrder)
                    ucRR.Case = EControlCase.Edit;
                if (!InCreationLanguage && UserId > -1 && Translate > -1)
                    ucRR.Case = EControlCase.ViewAllowTranslate;
                if (!InCreationLanguage && UserId > -1 && Translate == controlOrder)
                    ucRR.Case = EControlCase.Translate;

                ucRR.LocalResourceFile = "/DesktopModules/PlugghestControls/App_LocalResources/RichRichControl.ascx";
                phComponents.Controls.Add(ucRR);
            }
        }
예제 #14
0
 public void UpdatePluggComponent(PluggComponent pc)
 {
     using (IDataContext db = DataContext.Instance())
     {
         var rep = db.GetRepository<PluggComponent>();
         rep.Update(pc);
     }
 }
예제 #15
0
        private void callingAddPlugg(int orderid)
        {
            var id = hdnDDLtxt.Value;

            BaseHandler plugghandler = new BaseHandler();
            PluggComponent pc = new PluggComponent();
            pc.ComponentOrder = orderid + 1;
            pc.ComponentType = (EComponentType)Enum.Parse(typeof(EComponentType), id);
            plugghandler.AddComponent(p, pc);
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", new string[] { "edit=1", "language=" + curlan }));
        }
예제 #16
0
        protected void btnTest_Click(object sender, EventArgs e)
        {
            BaseHandler bh = new BaseHandler();
            PluggContainer p = new PluggContainer("en-US", 31);
            PluggComponent pc = new PluggComponent();
            pc.ComponentType = EComponentType.YouTube;
            pc.ComponentOrder = 3;
            //bh.AddComponent(p, pc);
            bh.DeleteComponent(p, 3);
            //List<PluggComponent> comps = pc.GetComponentList();

            //foreach(PluggComponent comp in comps)
            //{
            //    switch (comp.ComponentType)
            //    {
            //        case EComponentType.Label:
            //            PHText lbl = bh.GetCurrentVersionText(pc.CultureCode, comp.PluggComponentId, ETextItemType.PluggComponentLabel);
            //            Handle label
            //            break;
            //        case EComponentType.RichText:
            //            PHText rt = bh.GetCurrentVersionText(pc.CultureCode, comp.PluggComponentId, ETextItemType.PluggComponentRichText);
            //            Handle rich text
            //            break;
            //        case EComponentType.RichRichText:
            //            PHText rrt = bh.GetCurrentVersionText(pc.CultureCode, comp.PluggComponentId, ETextItemType.PluggComponentRichRichText);
            //            Handle richrich text
            //            break;
            //        case EComponentType.Latex:
            //            PHLatex lt = bh.GetCurrentVersionLatexText(pc.CultureCode, comp.PluggComponentId, ELatexItemType.PluggComponentLatex);
            //            Handle Latex text
            //            break;
            //        case EComponentType.YouTube:
            //            YouTube yt = bh.GetYouTubeByComponentId(comp.PluggComponentId);
            //            Handle YouTube
            //            break;
            //    }
            //}
            //PHText rrText = bh.GetCurrentVersionText(pc.CultureCode, comps[0].PluggComponentId, ETextItemType.PluggComponentRichRichText);
            //string myText = rrText.Text;

            //int x;
            //PluggComponent vv = comps[0];
            //foreach(PluggComponent c in comps)
            //{
            //    x = c.PluggComponentId;
            //}
            //pc.ThePlugg.CreatedByUserId = 1;
            //pc.ThePlugg.ModifiedByUserId = 1;
            //pc.ThePlugg.WhoCanEdit = EWhoCanEdit.Anyone;

            //pc.SetTitle("This is my Title");
            //pc.SetDescription("This is my description");

            //List<object> cmpData = new List<object>();

            //YouTube v = new YouTube();
            //v.YouTubeAuthor = "";
            //v.YouTubeCode = "asdasdasdas";
            //v.YouTubeComment = "";
            //v.YouTubeCreatedOn = DateTime.Now;
            //v.YouTubeDuration = 100;
            //v.YouTubeTitle = "This is my Title";
            //cmpData.Add(v);

            //PHText htmlText = new PHText();
            //htmlText.Text = "This is my Html text";
            //htmlText.ItemType = ETextItemType.PluggComponentRichRichText;
            //cmpData.Add(htmlText);

            //bh.SavePlugg(pc, cmpData);

            //PHLatex latexText = new PHLatex();
            //latexText.Text = "This is my Latex text";
            //latexText.ItemType = ELatexItemType.PluggComponentLatex;
            //cmpData.Add(latexText);

            //pc.LoadComponents();
            //switch (pc.TheComponents.GetType().Name)
            //{
            //    case "Aba":
            //        break;
            //}

            //pc.ThePlugg = bh.GetPlugg(1);
            //pc.LoadComponents();
            //foreach (var c in pc.TheComponents)
            //{
            //    switch (c.GetType().Name)
            //    {
            //        case "PHText":
            //            PHText xx = (PHText)c;
            //            string x = theTitle;
            //            break;
            //    }
            //}
        }
예제 #17
0
        public void SavePlugg(PluggContainer p, List <object> cs)
        {
            if (p.ThePlugg.CreatedInCultureCode != null && p.CultureCode != p.ThePlugg.CreatedInCultureCode)
            {
                throw new Exception("Cannot use SavePlugg unless you are saving it in the creation language.");
            }

            p.ThePlugg.CreatedInCultureCode = p.CultureCode;

            try
            {
                bool isNew = p.ThePlugg.PluggId == 0;

                //Temporary - to avoid login - remove soon
                p.ThePlugg.CreatedByUserId  = 1;
                p.ThePlugg.ModifiedByUserId = 1;

                //Save Plugg entity
                p.ThePlugg.ModifiedOnDate = DateTime.Now;

                if (isNew)
                {
                    p.ThePlugg.CreatedOnDate = DateTime.Now;
                    rep.CreatePlugg(p.ThePlugg);
                }
                else
                {
                    rep.UpdatePlugg(p.ThePlugg);
                }

                //Save Title
                if (p.TheTitle == null || p.TheTitle.Text == null)
                {
                    throw new Exception("Cannot Save Plugg. TheTitle cannot be null");
                }

                if (p.TheTitle.TextId == 0)
                {
                    p.TheTitle.ItemId            = p.ThePlugg.PluggId;
                    p.TheTitle.ItemType          = ETextItemType.PluggTitle;
                    p.TheTitle.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
                    p.TheTitle.CreatedByUserId   = p.ThePlugg.CreatedByUserId;
                    p.TheTitle.ModifiedByUserId  = p.ThePlugg.ModifiedByUserId;
                }
                SavePhTextInAllCc(p.TheTitle);  //Save or Update

                if (p.TheDescription != null && p.TheDescription.Text != null)
                {
                    if (p.TheDescription.TextId == 0)
                    {
                        p.TheDescription.ItemId            = p.ThePlugg.PluggId;
                        p.TheDescription.ItemType          = ETextItemType.PluggDescription;
                        p.TheDescription.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
                        p.TheDescription.CreatedByUserId   = p.ThePlugg.CreatedByUserId;
                        p.TheDescription.ModifiedByUserId  = p.ThePlugg.ModifiedByUserId;
                    }
                    SavePhTextInAllCc(p.TheDescription);
                }

                int            cmpOrder = 1;
                PluggComponent pc       = new PluggComponent();
                pc.PluggId = p.ThePlugg.PluggId;
                foreach (object cmp in cs)
                {
                    pc.ComponentOrder = cmpOrder;
                    switch (cmp.GetType().Name)
                    {
                    case "PHText":
                        PHText theText = (PHText)cmp;
                        switch (theText.ItemType)
                        {
                        case ETextItemType.PluggComponentRichRichText:
                            pc.ComponentType = EComponentType.RichRichText;
                            break;

                        case ETextItemType.PluggComponentRichText:
                            pc.ComponentType = EComponentType.RichText;
                            break;

                        case ETextItemType.PluggComponentLabel:
                            pc.ComponentType = EComponentType.Label;
                            break;
                        }
                        rep.CreatePluggComponent(pc);
                        theText.ItemId          = pc.PluggComponentId;
                        theText.CultureCode     = p.ThePlugg.CreatedInCultureCode;
                        theText.CreatedByUserId = p.ThePlugg.CreatedByUserId;
                        SavePhTextInAllCc(theText);
                        break;

                    case "PHLatex":
                        PHLatex theLatex = (PHLatex)cmp;
                        pc.ComponentType = EComponentType.Latex;
                        rep.CreatePluggComponent(pc);
                        theLatex.ItemId          = pc.PluggComponentId;
                        theLatex.CultureCode     = p.ThePlugg.CreatedInCultureCode;
                        theLatex.CreatedByUserId = p.ThePlugg.CreatedByUserId;
                        SaveLatexTextInAllCc(theLatex);
                        break;

                    case "YouTube":
                        pc.ComponentType = EComponentType.YouTube;
                        rep.CreatePluggComponent(pc);
                        YouTube theVideo = (YouTube)cmp;
                        theVideo.CreatedByUserId  = p.ThePlugg.CreatedByUserId;
                        theVideo.PluggComponentId = pc.PluggComponentId;
                        SaveYouTube(theVideo);
                        break;
                    }
                    cmpOrder++;
                }

                //Create PluggPage
                DNNHelper d        = new DNNHelper();
                string    pageUrl  = p.ThePlugg.PluggId.ToString();
                string    pageName = pageUrl + ": " + p.TheTitle.Text;
                TabInfo   newTab   = d.AddPluggPage(pageName, pageUrl);
                p.ThePlugg.TabId = newTab.TabID;
                rep.UpdatePlugg(p.ThePlugg);
            }
            catch (Exception)
            {
                //Todo: Update
                //DeletePlugg(p.ThePlugg);
                throw;
            }
        }
예제 #18
0
 private void LoadYouTube(PluggComponent c, int controlOrder)
 {
     YouTubeControl ucYT = (YouTubeControl)this.LoadControl("/DesktopModules/PlugghestControls/YouTubeControl.ascx");
     if (ucYT != null)
     {
         ucYT.ModuleConfiguration = this.ModuleConfiguration;
         ucYT.PluggComponentId = c.PluggComponentId;
         ucYT.CultureCode = CultureCode;
         ucYT.ControlOrder = controlOrder;
         ucYT.Case = EControlCase.View;
         if (InCreationLanguage & IsAuthorized & Edit > -1)
             ucYT.Case = EControlCase.ViewAllowEdit;
         if (InCreationLanguage & IsAuthorized & Edit == controlOrder)
             ucYT.Case = EControlCase.Edit;
         ucYT.LocalResourceFile = "/DesktopModules/PlugghestControls/App_LocalResources/YouTubeControl.ascx";
         phComponents.Controls.Add(ucYT);
     }
 }
예제 #19
0
        public void CreateBasicPlugg(PluggContainer p)
        {
            if (p.CultureCode == null || p.CultureCode == "")
                throw new Exception("Cannot Create Plugg. CutureCode cannot be null");

            if (p.TheTitle == null || p.TheTitle.Text == null || p.TheTitle.Text == "")
                throw new Exception("Cannot Save Plugg. Title cannot be null");

            p.ThePlugg.CreatedInCultureCode = p.CultureCode;
            p.ThePlugg.CreatedOnDate = DateTime.Now;
            p.ThePlugg.ModifiedByUserId = p.ThePlugg.CreatedByUserId;
            p.ThePlugg.ModifiedOnDate = p.ThePlugg.CreatedOnDate;
            p.ThePlugg.IsDeleted = false;
            p.ThePlugg.IsListed = true;
            rep.CreatePlugg(p.ThePlugg);

            //Save Title
            p.TheTitle.ItemId = p.ThePlugg.PluggId;
            p.TheTitle.ItemType = ETextItemType.PluggTitle;
            p.TheTitle.CultureCode = p.CultureCode;
            p.TheTitle.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
            p.TheTitle.CreatedByUserId = p.ThePlugg.CreatedByUserId;
            p.TheTitle.ModifiedByUserId = p.ThePlugg.ModifiedByUserId;
            SavePhTextInAllCc(p.TheTitle);  //Save or Update

            //Save Description
            if (p.TheDescription != null && p.TheDescription.Text != null && p.TheDescription.Text != "")
            {
                p.TheDescription.ItemId = p.ThePlugg.PluggId;
                p.TheDescription.ItemType = ETextItemType.PluggDescription;
                p.TheDescription.CultureCode = p.CultureCode;
                p.TheDescription.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
                p.TheDescription.CreatedByUserId = p.ThePlugg.CreatedByUserId;
                p.TheDescription.ModifiedByUserId = p.ThePlugg.ModifiedByUserId;
                SavePhTextInAllCc(p.TheDescription);
            }

            PluggComponent video = new PluggComponent();
            video.ComponentOrder = 1;
            video.ComponentType = EComponentType.YouTube;
            AddComponent(p, video);

            PluggComponent rrText = new PluggComponent();
            rrText.ComponentOrder = 2;
            rrText.ComponentType = EComponentType.RichRichText;
            p.TheComponents = null;
            AddComponent(p, rrText);

            //Create PluggPage
            DNNHelper d = new DNNHelper();
            string pageUrl = p.ThePlugg.PluggId.ToString();
            string pageName = pageUrl + ": " + p.TheTitle.Text;
            TabInfo newTab = d.AddPluggPage(pageName, pageUrl);
            p.ThePlugg.TabId = newTab.TabID;
            rep.UpdatePlugg(p.ThePlugg);
        }
예제 #20
0
 private void CreateBtnEdit(PluggComponent comp, PHText lbl, string CssClass, string ID)
 {
     Button editbtn = new Button();
     editbtn.CssClass = CssClass;
     editbtn.ID = ID;
     editbtn.Text = BtnEditTxt;
     editbtn.Click += (s, e) => { ImpGoogleTrans(comp, lbl); };
     divTitle.Controls.Add(editbtn);
 }
예제 #21
0
        public void SavePlugg(PluggContainer p, List<object> cs)
        {
            if (p.ThePlugg.CreatedInCultureCode != null && p.CultureCode != p.ThePlugg.CreatedInCultureCode)
                throw new Exception("Cannot use SavePlugg unless you are saving it in the creation language.");

            p.ThePlugg.CreatedInCultureCode = p.CultureCode;

            try
            {
                bool isNew = p.ThePlugg.PluggId == 0;

                //Temporary - to avoid login - remove soon
                p.ThePlugg.CreatedByUserId = 1;
                p.ThePlugg.ModifiedByUserId = 1;

                //Save Plugg entity
                p.ThePlugg.ModifiedOnDate = DateTime.Now;

                if (isNew)
                {
                    p.ThePlugg.CreatedOnDate = DateTime.Now;
                    rep.CreatePlugg(p.ThePlugg);
                }
                else
                    rep.UpdatePlugg(p.ThePlugg);

                //Save Title
                if (p.TheTitle == null || p.TheTitle.Text == null)
                    throw new Exception("Cannot Save Plugg. TheTitle cannot be null");

                if (p.TheTitle.TextId == 0)
                {
                    p.TheTitle.ItemId = p.ThePlugg.PluggId;
                    p.TheTitle.ItemType = ETextItemType.PluggTitle;
                    p.TheTitle.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
                    p.TheTitle.CreatedByUserId = p.ThePlugg.CreatedByUserId;
                    p.TheTitle.ModifiedByUserId = p.ThePlugg.ModifiedByUserId;
                }
                SavePhTextInAllCc(p.TheTitle);  //Save or Update

                if (p.TheDescription != null && p.TheDescription.Text != null)
                {
                    if (p.TheDescription.TextId == 0)
                    {
                        p.TheDescription.ItemId = p.ThePlugg.PluggId;
                        p.TheDescription.ItemType = ETextItemType.PluggDescription;
                        p.TheDescription.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
                        p.TheDescription.CreatedByUserId = p.ThePlugg.CreatedByUserId;
                        p.TheDescription.ModifiedByUserId = p.ThePlugg.ModifiedByUserId;
                    }
                    SavePhTextInAllCc(p.TheDescription);
                }

                int cmpOrder = 1;
                PluggComponent pc = new PluggComponent();
                pc.PluggId = p.ThePlugg.PluggId;
                foreach (object cmp in cs)
                {
                    pc.ComponentOrder = cmpOrder;
                    switch (cmp.GetType().Name)
                    {
                        case "PHText":
                            PHText theText = (PHText)cmp;
                            switch (theText.ItemType)
                            {
                                case ETextItemType.PluggComponentRichRichText:
                                    pc.ComponentType = EComponentType.RichRichText;
                                    break;
                                case ETextItemType.PluggComponentRichText:
                                    pc.ComponentType = EComponentType.RichText;
                                    break;
                                case ETextItemType.PluggComponentLabel:
                                    pc.ComponentType = EComponentType.Label;
                                    break;
                            }
                            rep.CreatePluggComponent(pc);
                            theText.ItemId = pc.PluggComponentId;
                            theText.CultureCode = p.ThePlugg.CreatedInCultureCode;
                            theText.CreatedByUserId = p.ThePlugg.CreatedByUserId;
                            SavePhTextInAllCc(theText);
                            break;
                        case "PHLatex":
                            PHLatex theLatex = (PHLatex)cmp;
                            pc.ComponentType = EComponentType.Latex;
                            rep.CreatePluggComponent(pc);
                            theLatex.ItemId = pc.PluggComponentId;
                            theLatex.CultureCode = p.ThePlugg.CreatedInCultureCode;
                            theLatex.CreatedByUserId = p.ThePlugg.CreatedByUserId;
                            SaveLatexTextInAllCc(theLatex);
                            break;
                        case "YouTube":
                            pc.ComponentType = EComponentType.YouTube;
                            rep.CreatePluggComponent(pc);
                            YouTube theVideo = (YouTube)cmp;
                            theVideo.CreatedByUserId = p.ThePlugg.CreatedByUserId;
                            theVideo.PluggComponentId = pc.PluggComponentId;
                            SaveYouTube(theVideo);
                            break;
                    }
                    cmpOrder++;
                }

                //Create PluggPage
                DNNHelper d = new DNNHelper();
                string pageUrl = p.ThePlugg.PluggId.ToString();
                string pageName = pageUrl + ": " + p.TheTitle.Text;
                TabInfo newTab = d.AddPluggPage(pageName, pageUrl);
                p.ThePlugg.TabId = newTab.TabID;
                rep.UpdatePlugg(p.ThePlugg);
            }
            catch (Exception)
            {
                //Todo: Update
                //DeletePlugg(p.ThePlugg);
                throw;
            }
        }
예제 #22
0
 private void CreateBtnImproveHumGoogleTrans(PluggComponent comp, PHText lbl, string css, string id,string BtnText)
 {
     Button btnImpHumTras = new Button();
     btnImpHumTras.CssClass = css;
     btnImpHumTras.ID = id;
     btnImpHumTras.Text = BtnText;
     btnImpHumTras.Click += (s, e) => { ImpGoogleTrans(comp, lbl); };
     divTitle.Controls.Add(btnImpHumTras);
 }
예제 #23
0
 private void CreateBtnYTEdit(PluggComponent comp, YouTube yt, int ytorderid, string CssClass, string ID)
 {
     Button editbtn = new Button();
     editbtn.CssClass = CssClass;
     editbtn.ID = ID;
     editbtn.Text = BtnEditTxt;
     editbtn.Click += (s, e) => { YouTubeEdit(ytorderid, comp, yt); };
     divTitle.Controls.Add(editbtn);
 }
예제 #24
0
 private void LoadLabel(PluggComponent c, int controlOrder)
 {
     LabelControl ucLC = (LabelControl)this.LoadControl("/DesktopModules/PlugghestControls/LabelControl.ascx");
     if (ucLC != null)
     {
         ucLC.ModuleConfiguration = this.ModuleConfiguration;
         ucLC.ItemId = c.PluggComponentId;
         ucLC.CultureCode = CultureCode;
         //ucRR.CreatedInCultureCode = pc.ThePlugg.CreatedInCultureCode;
         ucLC.ControlOrder = controlOrder;
         ucLC.ItemType = ETextItemType.PluggComponentLabel;
         ucLC.Case = EControlCase.View;
         if (InCreationLanguage & IsAuthorized & Edit > -1)
             ucLC.Case = EControlCase.ViewAllowEdit;
         if (InCreationLanguage & IsAuthorized & Edit == controlOrder)
             ucLC.Case = EControlCase.Edit;
         ucLC.LocalResourceFile = "/DesktopModules/PlugghestControls/App_LocalResources/LabelControl.ascx";
         phComponents.Controls.Add(ucLC);
     }
 }