Ejemplo n.º 1
0
        private void BindProfiles()
        {
            ddProfiles.Items.Clear();

            ArrayList list = new ArrayList();

            ListViewProfile[] mas = ListViewProfile.GetSystemProfiles(ClassName, _placeName);

            List <KeyValuePair <string, string> > summaryList = new List <KeyValuePair <string, string> >();

            foreach (ListViewProfile lvp in mas)
            {
                summaryList.Add(new KeyValuePair <string, string>(lvp.Id, "  " + CHelper.GetResFileString(lvp.Name)));
                list.Add(lvp.Id);
            }

            summaryList.Sort
            (
                delegate(KeyValuePair <string, string> kvp1,
                         KeyValuePair <string, string> kvp2)
            {
                return(Comparer <string> .Default.Compare(kvp1.Value, kvp2.Value));
            }
            );
            if (mas.Length > 0)
            {
                summaryList.Insert(0, new KeyValuePair <string, string>("-1", String.Format("[ {0} ]", GetGlobalResourceObject("IbnFramework.Incident", "SystemViews").ToString())));
            }

            ListViewProfile[] mas2 = ListViewProfile.GetProfiles(ClassName, _placeName, Mediachase.Ibn.Data.Services.Security.CurrentUserId);

            List <KeyValuePair <string, string> > summaryList2 = new List <KeyValuePair <string, string> >();

            foreach (ListViewProfile lvp in mas2)
            {
                if (!list.Contains(lvp.Id))
                {
                    summaryList2.Add(new KeyValuePair <string, string>(lvp.Id, "  " + CHelper.GetResFileString(lvp.Name)));
                }
            }

            summaryList2.Sort
            (
                delegate(KeyValuePair <string, string> kvp1,
                         KeyValuePair <string, string> kvp2)
            {
                return(Comparer <string> .Default.Compare(kvp1.Value, kvp2.Value));
            }
            );

            if (summaryList2.Count > 0)
            {
                summaryList.Add(new KeyValuePair <string, string>("-2", String.Format("[ {0} ]", GetGlobalResourceObject("IbnFramework.Incident", "UserViews").ToString())));
                summaryList.AddRange(summaryList2);
            }
            summaryList.Add(new KeyValuePair <string, string>("0", String.Format("[ {0} ]", GetGlobalResourceObject("IbnFramework.Incident", "NewIssueView").ToString())));

            ddProfiles.DataSource     = summaryList;
            ddProfiles.DataTextField  = "Value";
            ddProfiles.DataValueField = "Key";
            ddProfiles.DataBind();

            foreach (ListItem liItem in ddProfiles.Items)
            {
                if (liItem.Value == "-1" || liItem.Value == "-2")
                {
                    liItem.Enabled = false;
                    liItem.Attributes.Add("style", "color:#646464;");
                }
                if (liItem.Value == "0")
                {
                    liItem.Attributes.Add("style", "color:#333333;font-weight:bold;");
                }
            }

            HtmlLink linkRss = (HtmlLink)this.Page.FindControl("rssLink");

            if (linkRss != null)
            {
                linkRss.Href = "";
                linkRss.Attributes.Add("title", string.Empty);
            }
        }
Ejemplo n.º 2
0
 protected void btnSearch_Click(object sender, ImageClickEventArgs e)
 {
     //фильтр по key-textbox
     _pc[ClassName + "_" + KeywordFilterKey] = txtSearch.Text;
     CHelper.RequireBindGrid();
 }
Ejemplo n.º 3
0
        private void BindData()
        {
            if (Mediachase.IBN.Business.ToDo.CanCreate(ProjectId))
            {
                TypeList.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Task", "ToDoType").ToString(), (ObjectTypes.ToDo).ToString()));
            }
            if (Mediachase.IBN.Business.Task.CanCreate(ProjectId))
            {
                TypeList.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Task", "TaskType").ToString(), (ObjectTypes.Task).ToString()));
            }
            if (TypeList.Items.Count > 0)
            {
                TypeList.Items[0].Selected = true;
            }

            // Priority
            using (IDataReader reader = Mediachase.IBN.Business.ToDo.GetListPriorities())
            {
                while (reader.Read())
                {
                    string text  = CHelper.GetResFileString(reader["PriorityName"].ToString());
                    string value = reader["PriorityId"].ToString();
                    PriorityList1.Items.Add(new ListItem(text, value));
                    PriorityList2.Items.Add(new ListItem(text, value));
                    PriorityList3.Items.Add(new ListItem(text, value));
                    PriorityList4.Items.Add(new ListItem(text, value));
                    PriorityList5.Items.Add(new ListItem(text, value));
                    PriorityList6.Items.Add(new ListItem(text, value));
                    PriorityList7.Items.Add(new ListItem(text, value));
                    PriorityList8.Items.Add(new ListItem(text, value));
                }
            }
            string normalPriority = ((int)Priority.Normal).ToString();

            CHelper.SafeSelect(PriorityList1, normalPriority);
            CHelper.SafeSelect(PriorityList2, normalPriority);
            CHelper.SafeSelect(PriorityList3, normalPriority);
            CHelper.SafeSelect(PriorityList4, normalPriority);
            CHelper.SafeSelect(PriorityList5, normalPriority);
            CHelper.SafeSelect(PriorityList6, normalPriority);
            CHelper.SafeSelect(PriorityList7, normalPriority);
            CHelper.SafeSelect(PriorityList8, normalPriority);

            // Resources
            // UserId, FirstName, LastName, IsExternal
            using (IDataReader reader = Project.GetListTeamMemberNamesWithManager(ProjectId))
            {
                while (reader.Read())
                {
                    string text  = String.Concat(reader["LastName"].ToString(), " ", reader["FirstName"].ToString());
                    string value = reader["UserId"].ToString();
                    ResourcesList1.Items.Add(new ListItem(text, value));
                    ResourcesList2.Items.Add(new ListItem(text, value));
                    ResourcesList3.Items.Add(new ListItem(text, value));
                    ResourcesList4.Items.Add(new ListItem(text, value));
                    ResourcesList5.Items.Add(new ListItem(text, value));
                    ResourcesList6.Items.Add(new ListItem(text, value));
                    ResourcesList7.Items.Add(new ListItem(text, value));
                    ResourcesList8.Items.Add(new ListItem(text, value));
                }
            }
            string currentUserId = Security.UserID.ToString();

            CHelper.SafeSelect(ResourcesList1, currentUserId);
            CHelper.SafeSelect(ResourcesList2, currentUserId);
            CHelper.SafeSelect(ResourcesList3, currentUserId);
            CHelper.SafeSelect(ResourcesList4, currentUserId);
            CHelper.SafeSelect(ResourcesList5, currentUserId);
            CHelper.SafeSelect(ResourcesList6, currentUserId);
            CHelper.SafeSelect(ResourcesList7, currentUserId);
            CHelper.SafeSelect(ResourcesList8, currentUserId);

            // Dates
            DateTime dt         = DateTime.Today.AddHours(DateTime.UtcNow.Hour + 1);
            DateTime startDate  = User.GetLocalDate(Security.CurrentUser.TimeZoneId, dt);
            DateTime finishDate = startDate.AddDays(1);

            StartDate1.SelectedDate  = StartDate2.SelectedDate = StartDate3.SelectedDate = StartDate4.SelectedDate = StartDate5.SelectedDate = StartDate6.SelectedDate = StartDate7.SelectedDate = StartDate8.SelectedDate = startDate;
            FinishDate1.SelectedDate = FinishDate2.SelectedDate = FinishDate3.SelectedDate = FinishDate4.SelectedDate = FinishDate5.SelectedDate = FinishDate6.SelectedDate = FinishDate7.SelectedDate = FinishDate8.SelectedDate = finishDate;
        }
Ejemplo n.º 4
0
 public void Invoke(object Sender, object Element)
 {
     CHelper.AddToContext("NeedToChangeDataSource", true);
 }
Ejemplo n.º 5
0
        public void BindData(MetaField field)
        {
            string url = CHelper.GetAbsolutePath(String.Format("/Apps/MetaUI/Pages/Public/SelectMultiReference.aspx?type={0}&btn={1}", field.GetMetaType().Name, Page.ClientScript.GetPostBackEventReference(btnRefresh, "xxx")));

            ibSelect.OnClientClick = String.Format("OpenPopUpWindow(\"{0}\", 640, 480, 1); return false;", url);
        }
Ejemplo n.º 6
0
        public bool LoadTheme(string XmlPath, string ElementName, XPathNavigator navigator, int SkinIndex)
        {
            string item = XmlPath + "/" + ElementName;

            _ThemeLoaded = true;

            _ThemeLoaded &= CHelper.GetValueFromXML(item + "/Skin", navigator, ref _Theme.TextureName, String.Empty);
            _ThemeLoaded &= CHelper.GetValueFromXML(item + "/SkinArrowLeft", navigator, ref _Theme.TextureArrowLeftName, String.Empty);
            _ThemeLoaded &= CHelper.GetValueFromXML(item + "/SkinArrowRight", navigator, ref _Theme.TextureArrowRightName, String.Empty);

            _ThemeLoaded &= CHelper.GetValueFromXML(item + "/SkinSelected", navigator, ref _Theme.STextureName, String.Empty);
            _ThemeLoaded &= CHelper.GetValueFromXML(item + "/SkinArrowLeftSelected", navigator, ref _Theme.STextureArrowLeftName, String.Empty);
            _ThemeLoaded &= CHelper.GetValueFromXML(item + "/SkinArrowRightSelected", navigator, ref _Theme.STextureArrowRightName, String.Empty);

            _ThemeLoaded &= CHelper.GetValueFromXML(item + "/SkinHighlighted", navigator, ref _Theme.HTextureName, String.Empty);

            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/X", navigator, ref Rect.X);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/Y", navigator, ref Rect.Y);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/Z", navigator, ref Rect.Z);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/W", navigator, ref Rect.W);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/H", navigator, ref Rect.H);

            if (CHelper.GetValueFromXML(item + "/Color", navigator, ref _Theme.ColorName, String.Empty))
            {
                _ThemeLoaded &= CTheme.GetColor(_Theme.ColorName, SkinIndex, ref Color);
            }
            else
            {
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/R", navigator, ref Color.R);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/G", navigator, ref Color.G);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/B", navigator, ref Color.B);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/A", navigator, ref Color.A);
            }

            if (CHelper.GetValueFromXML(item + "/SColor", navigator, ref _Theme.SColorName, String.Empty))
            {
                _ThemeLoaded &= CTheme.GetColor(_Theme.SColorName, SkinIndex, ref SColor);
            }
            else
            {
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SR", navigator, ref SColor.R);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SG", navigator, ref SColor.G);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SB", navigator, ref SColor.B);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SA", navigator, ref SColor.A);
            }

            if (CHelper.GetValueFromXML(item + "/HColor", navigator, ref _Theme.HColorName, String.Empty))
            {
                _ThemeLoaded &= CTheme.GetColor(_Theme.HColorName, SkinIndex, ref HColor);
            }
            else
            {
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/HR", navigator, ref HColor.R);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/HG", navigator, ref HColor.G);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/HB", navigator, ref HColor.B);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/HA", navigator, ref HColor.A);
            }

            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowLeftX", navigator, ref RectArrowLeft.X);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowLeftY", navigator, ref RectArrowLeft.Y);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowLeftZ", navigator, ref RectArrowLeft.Z);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowLeftW", navigator, ref RectArrowLeft.W);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowLeftH", navigator, ref RectArrowLeft.H);

            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowRightX", navigator, ref RectArrowRight.X);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowRightY", navigator, ref RectArrowRight.Y);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowRightZ", navigator, ref RectArrowRight.Z);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowRightW", navigator, ref RectArrowRight.W);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowRightH", navigator, ref RectArrowRight.H);

            if (CHelper.GetValueFromXML(item + "/ArrowColor", navigator, ref _Theme.ArrowColorName, String.Empty))
            {
                _ThemeLoaded &= CTheme.GetColor(_Theme.ArrowColorName, SkinIndex, ref ColorArrow);
            }
            else
            {
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowR", navigator, ref ColorArrow.R);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowG", navigator, ref ColorArrow.G);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowB", navigator, ref ColorArrow.B);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowA", navigator, ref ColorArrow.A);
            }

            if (CHelper.GetValueFromXML(item + "/ArrowSColor", navigator, ref _Theme.SArrowColorName, String.Empty))
            {
                _ThemeLoaded &= CTheme.GetColor(_Theme.SArrowColorName, SkinIndex, ref SColorArrow);
            }
            else
            {
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowSR", navigator, ref SColorArrow.R);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowSG", navigator, ref SColorArrow.G);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowSB", navigator, ref SColorArrow.B);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/ArrowSA", navigator, ref SColorArrow.A);
            }

            if (CHelper.GetValueFromXML(item + "/TextColor", navigator, ref _Theme.TextColorName, String.Empty))
            {
                _ThemeLoaded &= CTheme.GetColor(_Theme.TextColorName, SkinIndex, ref TextColor);
            }
            else
            {
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/TextR", navigator, ref TextColor.R);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/TextG", navigator, ref TextColor.G);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/TextB", navigator, ref TextColor.B);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/TextA", navigator, ref TextColor.A);
            }

            if (CHelper.GetValueFromXML(item + "/TextSColor", navigator, ref _Theme.STextColorName, String.Empty))
            {
                _ThemeLoaded &= CTheme.GetColor(_Theme.STextColorName, SkinIndex, ref STextColor);
            }
            else
            {
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/TextSR", navigator, ref STextColor.R);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/TextSG", navigator, ref STextColor.G);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/TextSB", navigator, ref STextColor.B);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/TextSA", navigator, ref STextColor.A);
            }

            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/TextH", navigator, ref TextH);
            if (CHelper.TryGetFloatValueFromXML(item + "/TextRelativeX", navigator, ref TextRelativeX))
            {
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/TextRelativeX", navigator, ref TextRelativeX);
            }
            if (CHelper.TryGetFloatValueFromXML(item + "/TextRelativeY", navigator, ref TextRelativeY))
            {
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/TextRelativeY", navigator, ref TextRelativeY);
            }
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/TextMaxW", navigator, ref MaxW);
            _ThemeLoaded &= CHelper.GetValueFromXML(item + "/TextFont", navigator, ref _Theme.TextFont, "Normal");
            _ThemeLoaded &= CHelper.TryGetEnumValueFromXML <EStyle>(item + "/TextStyle", navigator, ref _Theme.TextStyle);

            _ThemeLoaded &= CHelper.TryGetIntValueFromXML(item + "/NumVisible", navigator, ref _NumVisible);

            if (_ThemeLoaded)
            {
                _Theme.Name = ElementName;
                LoadTextures();
            }
            return(_ThemeLoaded);
        }
Ejemplo n.º 7
0
    int calc_cellcount_to_eat(short cell, List <short> victim_cells)
    {
        List <short> cells_to_eat = CHelper.find_neighbor_cells(cell, victim_cells, 1);

        return(cells_to_eat.Count);
    }
Ejemplo n.º 8
0
        private void BindData1N()
        {
            PrimaryObjectLink.Visible = true;
            PrimaryObjectList.Visible = false;
            RelatedObjectLink.Visible = false;
            RelatedObjectList.Visible = true;

            PrimaryObjectLink.Text        = CHelper.GetResFileString(mc.FriendlyName);
            PrimaryObjectLink.NavigateUrl = String.Format(CultureInfo.InvariantCulture,
                                                          "{0}?class={1}&Tab=Rel1N", ReturnUrl, ClassName);

            if (mfRef == null)                  // new 1:N
            {
                FillObjectList(RelatedObjectList);
                RebindFieldInfoByRelatedObject();

                NameTextBox.Text         = ClassName;
                FriendlyNameTextBox.Text = CHelper.GetResFileString(mc.FriendlyName);

                // Display Block
                RebindDisplayInfo(ClassName);

                DisplayText.Text = CHelper.GetResFileString(MetaDataWrapper.GetMetaClassByName(RelatedObjectList.SelectedValue).PluralName);
            }
            else              // edit 1:N
            {
                RelatedObjectList.Items.Add(new ListItem(CHelper.GetResFileString(mcRef.FriendlyName), RefClassName));
                RelatedObjectList.Enabled = false;

                FieldBlockHeader.Title = String.Format(CultureInfo.InvariantCulture,
                                                       "{0} \"{1}\"",
                                                       ListManager.MetaClassIsList(RefClassName)
                                                ? GetGlobalResourceObject("IbnFramework.ListInfo", "List")
                                                : GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Object"),
                                                       CHelper.GetResFileString(MetaDataWrapper.GetMetaClassByName(RefClassName).FriendlyName));

                NameTextBox.Text    = mfRef.Name;
                NameTextBox.Enabled = false;

                FriendlyNameTextBox.Text = mfRef.FriendlyName;

                AllowNullsCheckBox.Checked = mfRef.IsNullable;
                AllowNullsCheckBox.Enabled = false;

                FormsRow.Visible = false;

                // Display Block
                RebindDisplayInfo(ClassName);

                CHelper.SafeSelect(DisplayRegion, mfRef.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceDisplayBlock, notSetValue));

                DisplayText.Text      = mfRef.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceDisplayText, CHelper.GetResFileString(mcRef.PluralName));
                DisplayOrderText.Text = mfRef.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceDisplayOrder, "10000");

                if (DisplayRegion.SelectedValue == notSetValue)
                {
                    DisplayTextRow.Visible  = false;
                    DisplayOrderRow.Visible = false;
                }
                else
                {
                    DisplayTextRow.Visible  = true;
                    DisplayOrderRow.Visible = true;
                }
            }

            MainBlockHeader.Title = GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Relation1N").ToString();

            CancelButton.Attributes.Add("onclick",
                                        String.Format(CultureInfo.InvariantCulture,
                                                      "window.location.href='{0}?class={1}&Tab=Rel1N'; return false;",
                                                      ResolveClientUrl(ReturnUrl),
                                                      ClassName));
        }
Ejemplo n.º 9
0
        protected void lbNewForm_Click(object sender, EventArgs e)
        {
            string param = Request.Params.Get("__EVENTARGUMENT");

            if (String.IsNullOrEmpty(param))
            {
                return;
            }

            FormDocumentData = (FormDocument)Session[param];

            MetaClassName = FormDocumentData.MetaClassName;
            FormName      = FormDocumentData.Name;

            fRenderer.FormDocumentData = FormDocumentData;
            fRenderer.DataBind();

            #region Visibility Elements
            if (CanAddNewForm)
            {
                bool changeForms = (ddClasses.SelectedItem == null || ddClasses.SelectedValue != MetaClassName);

                CHelper.SafeSelect(ddClasses, MetaClassName);
                if (ddClasses.SelectedItem == null || ddClasses.SelectedValue != MetaClassName)
                {
                    ddClasses.Visible        = false;
                    lblTempClassName.Visible = true;
                    lblTempClassName.Text    = CHelper.GetResFileString(MetaDataWrapper.GetMetaClassByName(MetaClassName).FriendlyName);
                }
                else
                {
                    ddClasses.Visible        = true;
                    lblTempClassName.Visible = false;
                }

                if (changeForms)
                {
                    ddFormName.Visible      = false;
                    lblTempFormName.Visible = true;
                    lblTempFormName.Text    = CHelper.GetFormName(FormName);
                }
                else
                {
                    CHelper.SafeSelect(ddFormName, FormName);
                    if (ddFormName.SelectedItem == null || ddFormName.SelectedValue != FormName)
                    {
                        ddFormName.Visible      = false;
                        lblTempFormName.Visible = true;
                        lblTempFormName.Text    = CHelper.GetFormName(FormName);
                    }
                    else
                    {
                        ddFormName.Visible      = true;
                        lblTempFormName.Visible = false;
                    }
                }
            }
            else
            {
                lblTempClassName.Text = CHelper.GetResFileString(MetaDataWrapper.GetMetaClassByName(MetaClassName).FriendlyName);
                lblTempFormName.Text  = CHelper.GetFormName(FormName);
            }

            lblTableName.Text = CHelper.GetResFileString(MetaDataWrapper.GetMetaClassByName(MetaClassName).FriendlyName);
            lblFormName.Text  = CHelper.GetFormName(FormName);

            if (FormDocumentData == null)
            {
                ddFormName.Enabled = false;
                tblMove.Visible    = false;
                tblLinks.Visible   = false;
            }
            else
            {
                ddFormName.Enabled = true;
                tblMove.Visible    = true;
                tblLinks.Visible   = true;

                if (MetaUIManager.MetaUITypeIsSystem(FormDocumentData.MetaClassName, FormDocumentData.MetaUITypeId))
                {
                    lblFormName.Text = CHelper.GetFormName(FormDocumentData.Name);
                }
                else
                {
                    lblFormName.Text = String.Format("{0} ({1})", CHelper.GetFormName(FormDocumentData.Name), CHelper.GetFormName(FormDocumentData.MetaUITypeId));
                }
            }
            #endregion
        }
Ejemplo n.º 10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     pT.Title = CHelper.GetResFileString("{IbnFramework.Global:_mc_TimeManagement}");
 }
Ejemplo n.º 11
0
        private void ApplyActions()
        {
            imgLeft.ImageUrl  = CHelper.GetAbsolutePath("Images/IbnFramework/Arrows/Left.gif");
            imgUp.ImageUrl    = CHelper.GetAbsolutePath("Images/IbnFramework/Arrows/Up.gif");
            imgRight.ImageUrl = CHelper.GetAbsolutePath("Images/IbnFramework/Arrows/Right.gif");
            imgDown.ImageUrl  = CHelper.GetAbsolutePath("Images/IbnFramework/Arrows/Down.gif");

            imgLeft.Style.Add("cursor", "pointer");
            imgUp.Style.Add("cursor", "pointer");
            imgRight.Style.Add("cursor", "pointer");
            imgDown.Style.Add("cursor", "pointer");

            string clientID = fRenderer.TableContainer;

            imgLeft.Attributes.Add("onclick", String.Format("__doPostBack('{1}', $find('{0}').getSelection());", clientID, lbLeft.UniqueID));
            imgUp.Attributes.Add("onclick", String.Format("__doPostBack('{1}', $find('{0}').getSelection());", clientID, lbTop.UniqueID));
            imgRight.Attributes.Add("onclick", String.Format("__doPostBack('{1}', $find('{0}').getSelection());", clientID, lbRight.UniqueID));
            imgDown.Attributes.Add("onclick", String.Format("__doPostBack('{1}', $find('{0}').getSelection());", clientID, lbDown.UniqueID));

            lbRemoveField.Attributes.Add("onclick", String.Format("if(confirm('{2}')){{__doPostBack('{1}', $find('{0}').getSelection());}} else return false;", clientID, lbRemoveField.UniqueID, GetGlobalResourceObject("IbnFramework.MetaForm", "WarningField").ToString()));
            lbRemoveSection.Attributes.Add("onclick", String.Format("if(confirm('{2}')){{__doPostBack('{1}', $find('{0}').getSelection());}} else return false;", clientID, lbRemoveSection.UniqueID, GetGlobalResourceObject("IbnFramework.MetaForm", "WarningSection").ToString()));

            if (CanAddNewForm)
            {
                lblNewForm.Text = String.Format(scriptNewForm,
                                                String.Format("{2}?btn={0}&class={1}",
                                                              lbNewForm.UniqueID, ddClasses.SelectedItem != null ? ddClasses.SelectedValue : "",
                                                              CHelper.GetAbsolutePath("/Apps/MetaUI/Pages/Public/FormDocumentEdit.aspx")),
                                                GetGlobalResourceObject("IbnFramework.MetaForm", "AddForm").ToString(),
                                                "null");
            }

            string uid = Guid.NewGuid().ToString("N");

            hFieldKey.Value  = uid;
            Session[uid]     = FormDocumentData;
            lblEditForm.Text = String.Format(scriptNewForm,
                                             String.Format("{0}?uid={1}&btn={2}",
                                                           CHelper.GetAbsolutePath("/Apps/MetaUI/Pages/Public/FormDocumentEdit.aspx"),
                                                           uid, lbNewForm.UniqueID),
                                             GetGlobalResourceObject("IbnFramework.MetaForm", "EditForm").ToString(),
                                             "null");

            lblNewSection.Text = String.Format(scriptNewSection,
                                               String.Format("{0}?uid={1}&btn={2}",
                                                             CHelper.GetAbsolutePath("/Apps/MetaUI/Pages/Public/FormSectionEdit.aspx"),
                                                             uid, lbAddSection.UniqueID),
                                               GetGlobalResourceObject("IbnFramework.MetaForm", "AddSection").ToString(),
                                               "null");

            lblEditSection.Text = String.Format(scriptNewSection,
                                                String.Format("{0}?uid={1}&btn={2}",
                                                              CHelper.GetAbsolutePath("/Apps/MetaUI/Pages/Public/FormSectionEdit.aspx"),
                                                              uid, lbAddSection.UniqueID),
                                                GetGlobalResourceObject("IbnFramework.MetaForm", "EditSection").ToString(),
                                                "'" + clientID + "'");

            lblAddField.Text = String.Format(scriptNewItem,
                                             String.Format("{0}?add=1&uid={1}&btn={2}",
                                                           CHelper.GetAbsolutePath("/Apps/MetaUI/Pages/Public/FormItemEdit.aspx"),
                                                           uid, lbAddSection.UniqueID),
                                             GetGlobalResourceObject("IbnFramework.MetaForm", "AddField").ToString(),
                                             "'" + clientID + "'");

            lblEditField.Text = String.Format(scriptNewItem,
                                              String.Format("{0}?uid={1}&btn={2}",
                                                            CHelper.GetAbsolutePath("/Apps/MetaUI/Pages/Public/FormItemEdit.aspx"),
                                                            uid, lbAddSection.UniqueID),
                                              GetGlobalResourceObject("IbnFramework.MetaForm", "EditField").ToString(),
                                              "'" + clientID + "'");
        }
Ejemplo n.º 12
0
        private void BindRenderer()
        {
            FormDocumentData = null;
            try
            {
                FormDocumentData = FormDocument.Load(MetaClassName, FormName);

                if (FormDocumentData == null)
                {
                    FormDocumentData = FormController.ReCreateFormDocument(MetaClassName, FormName);
                }

                if (MetaUIManager.MetaUITypeIsSystem(FormDocumentData.MetaClassName, FormDocumentData.MetaUITypeId) ||
                    FormName == FormDocumentData.MetaUITypeId)
                {
                    lblFormName.Text = CHelper.GetFormName(FormName);
                }
                else
                {
                    lblFormName.Text = String.Format("{0} ({1})", CHelper.GetFormName(FormName), CHelper.GetFormName(FormDocumentData.MetaUITypeId));
                }
            }
            catch { }
            BindRendererInner();
        }
Ejemplo n.º 13
0
        private void FillObjectList(DropDownList lst)
        {
            Dictionary <string, string>           items;
            List <KeyValuePair <string, string> > sortedItems;

            // Meta Classes
            items = new Dictionary <string, string>();
            foreach (MetaClass metaClass in DataContext.Current.MetaModel.MetaClasses)
            {
                if (!metaClass.IsBridge &&
                    !metaClass.IsCard &&
                    !String.IsNullOrEmpty(metaClass.TitleFieldName) &&
                    CHelper.CheckMetaClassIsPublic(metaClass) &&
                    !ListManager.MetaClassIsList(metaClass))
                {
                    items.Add(metaClass.Name, CHelper.GetResFileString(metaClass.FriendlyName));
                }
            }

            // [BusinessObjects] Block
            if (items.Count > 0)
            {
                ListItem li = new ListItem(GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "BusinessObjectsBlock").ToString(), businessObjectsBlock);
                lst.Items.Add(li);
            }

            // SortByValue
            sortedItems = new List <KeyValuePair <string, string> >(items);
            sortedItems.Sort(
                delegate(KeyValuePair <string, string> firstPair, KeyValuePair <string, string> nextPair)
            {
                return(firstPair.Value.CompareTo(nextPair.Value));
            }
                );

            // add metaclasses
            foreach (KeyValuePair <string, string> kvp in sortedItems)
            {
                string text = String.Format(CultureInfo.InvariantCulture, "   {0}", kvp.Value);
                lst.Items.Add(new ListItem(text, kvp.Key));
            }

            // Lists
            items = new Dictionary <string, string>();
            foreach (MetaClass metaClass in DataContext.Current.MetaModel.MetaClasses)
            {
                string name = metaClass.Name;
                if (!metaClass.IsBridge &&
                    !metaClass.IsCard &&
                    !String.IsNullOrEmpty(metaClass.TitleFieldName) &&
                    ListManager.MetaClassIsList(name))
                {
                    // Check Security
                    int listId = ListManager.GetListIdByClassName(name);
                    if (Mediachase.IBN.Business.ListInfoBus.CanRead(listId))
                    {
                        items.Add(name, CHelper.GetResFileString(metaClass.FriendlyName));
                    }
                }
            }

            // [Lists] Block
            if (items.Count > 0)
            {
                ListItem li = new ListItem(GetGlobalResourceObject("IbnFramework.ListInfo", "ListsBlock").ToString(), listsBlock);
                lst.Items.Add(li);
            }

            // SortByValue
            sortedItems = new List <KeyValuePair <string, string> >(items);
            sortedItems.Sort(
                delegate(KeyValuePair <string, string> firstPair, KeyValuePair <string, string> nextPair)
            {
                return(firstPair.Value.CompareTo(nextPair.Value));
            }
                );

            // add lists
            foreach (KeyValuePair <string, string> kvp in sortedItems)
            {
                string text = String.Format(CultureInfo.InvariantCulture, "   {0}", kvp.Value);
                lst.Items.Add(new ListItem(text, kvp.Key));
            }

            lst.SelectedIndex = 1;
        }
Ejemplo n.º 14
0
		/// <summary>
		/// Loads all cover which are defined in the cover config file.
		/// </summary>
        private static void LoadCover(string coverThemeName)
        {
            SCoverTheme coverTheme = new SCoverTheme();

            coverTheme = CoverTheme(coverThemeName);

            if (coverTheme.Name != String.Empty)
            {

                bool loaded = false;
                XPathDocument xPathDoc = null;
                XPathNavigator navigator = null;

                try
                {
                    xPathDoc = new XPathDocument(Path.Combine(CSettings.sFolderCover, coverTheme.File));
                    navigator = xPathDoc.CreateNavigator();
                    loaded = true;
                }
                catch (Exception)
                {
                    loaded = false;
                    if (navigator != null)
                        navigator = null;

                    if (xPathDoc != null)
                        xPathDoc = null;
                }

                if (loaded)
                {
                    lock (_MutexCover)
                    {
                        _Cover.Clear();
                        List<string> cover = CHelper.GetValuesFromXML("Cover", navigator);
                        for (int i = 0; i < cover.Count; i++)
                        {
                            SCover sk = new SCover();
                            string name = String.Empty;
                            string value = String.Empty;
                            CHelper.GetValueFromXML("//root/Cover/" + cover[i] + "/Name", navigator, ref name, String.Empty);
                            CHelper.GetValueFromXML("//root/Cover/" + cover[i] + "/Path", navigator, ref value, String.Empty);
                            sk.Name = name;
                            sk.Value = Path.Combine(coverTheme.Folder,value);
                            if (File.Exists(Path.Combine(CSettings.sFolderCover, Path.Combine(coverTheme.Folder, value))))
                            {
                                sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.sFolderCover, Path.Combine(coverTheme.Folder, value)));
                            }
                            else
                            {
                                sk.Texture = _NoCover;
                            }

                            _Cover.Add(sk);

                            if (sk.Name == "NoCover")
                            {
                                _NoCover = sk.Texture;
                            }
                        }
                    }
                }

                CHelper Helper = new CHelper();
                List<string> files = new List<string>();

                files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.png", true, true));
                files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.jpg", true, true));
                files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.jpeg", true, true));
                files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.bmp", true, true));


                foreach (string file in files)
                {
                    string name = Path.GetFileNameWithoutExtension(file);

                    if (!CoverExists(name))
                    {
                        SCover sk = new SCover();

                        string value = String.Empty;

                        sk.Name = name;
                        sk.Value = Path.Combine(coverTheme.Folder,Path.GetFileName(file));

                        sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.sFolderCover, sk.Value));

                        _Cover.Add(sk);
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public override bool HandleMouse(ref SMouseEvent mouseEvent, SScreenSongOptions songOptions)
        {
            if (!songOptions.Selection.RandomOnly || (!CBase.Songs.IsInCategory() && songOptions.Selection.CategoryChangeAllowed))
            {
                if (mouseEvent.Wheel != 0 && CHelper.IsInBounds(_ScrollRect, mouseEvent))
                {
                    _UpdateList(_Offset + _NumW * mouseEvent.Wheel);
                }

                int  lastSelection     = _SelectionNr;
                int  i                 = 0;
                bool somethingSelected = false;
                foreach (CStatic tile in _Tiles)
                {
                    if (tile.Texture != _CoverBGTexture && CHelper.IsInBounds(tile.Rect, mouseEvent))
                    {
                        somethingSelected = true;
                        _SelectionNr      = i + _Offset;
                        if (!CBase.Songs.IsInCategory())
                        {
                            _PreviewNr = i + _Offset;
                        }
                        break;
                    }
                    i++;
                }
                //Reset selection only if we moved out of the rect to avoid loosing it when selecting random songs
                if (_MouseWasInRect && !somethingSelected)
                {
                    _SelectionNr = -1;
                }
                if (mouseEvent.Sender == ESender.WiiMote && _SelectionNr != lastSelection && _SelectionNr != -1)
                {
                    CBase.Controller.SetRumble(0.050f);
                }
            }
            _MouseWasInRect = CHelper.IsInBounds(Rect, mouseEvent);

            if (mouseEvent.RB)
            {
                if (CBase.Songs.IsInCategory() && CBase.Songs.GetNumCategories() > 0 && CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_ON &&
                    songOptions.Selection.CategoryChangeAllowed)
                {
                    _LeaveCategory();
                    return(true);
                }
                if (CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && !songOptions.Selection.PartyMode)
                {
                    CBase.Graphics.FadeTo(EScreen.Main);
                    return(true);
                }
            }
            else if (mouseEvent.LB)
            {
                if (_SelectionNr >= 0 && _MouseWasInRect)
                {
                    if (CBase.Songs.IsInCategory())
                    {
                        if (_PreviewNr == _SelectionNr)
                        {
                            return(false);
                        }
                        _PreviewSelectedSong();
                    }
                    else
                    {
                        EnterSelectedCategory();
                    }
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 16
0
        private static void ListThemes()
        {
            CHelper Helper = new CHelper();
            _Themes.Clear();

            string path = Path.Combine(Directory.GetCurrentDirectory(), CSettings.sFolderThemes);
            List<string> files = Helper.ListFiles(path, "*.xml", false);

            foreach (string file in files)
            {
                bool loaded = false;
                XPathDocument xPathDoc = null;
                XPathNavigator navigator = null;

                try
                {
                    xPathDoc = new XPathDocument(Path.Combine(path, file));
                    navigator = xPathDoc.CreateNavigator();
                    loaded = true;
                }
                catch (Exception e)
                {
                    CLog.LogError("Error loading theme " + file + ": " + e.Message);
                    loaded = false;
                    if (navigator != null)
                        navigator = null;

                    if (xPathDoc != null)
                        xPathDoc = null;
                }

                if (loaded)
                {
                    Theme theme = new Theme();

                    int version = 0;
                    CHelper.TryGetIntValueFromXML("//root/ThemeSystemVersion", navigator, ref version);

                    if (version == ThemeSystemVersion)
                    {
                        CHelper.GetValueFromXML("//root/Info/Name", navigator, ref theme.Name, String.Empty);
                        if (theme.Name != String.Empty)
                        {
                            CHelper.GetValueFromXML("//root/Info/Author", navigator, ref theme.Author, String.Empty);
                            CHelper.GetValueFromXML("//root/Info/SkinFolder", navigator, ref theme.SkinFolder, String.Empty);
                            CHelper.TryGetIntValueFromXML("//root/Info/ThemeVersionMajor", navigator, ref theme.ThemeVersionMajor);
                            CHelper.TryGetIntValueFromXML("//root/Info/ThemeVersionMinor", navigator, ref theme.ThemeVersionMinor);
                            theme.Path = path;
                            theme.FileName = file;

                            _Themes.Add(theme);
                        }
                    }
                    else
                    {
                        string msg = "Can't load Theme \"" + file + "\", ";
                        if (version < ThemeSystemVersion)
                            msg += "the file ist outdated! ";
                        else
                            msg += "the file is for newer program versions! ";

                        msg += "Current ThemeSystemVersion is " + ThemeSystemVersion.ToString();
                        CLog.LogError(msg);
                    }
                }
            }
        }
Ejemplo n.º 17
0
 void Page_PreRenderComplete(object sender, EventArgs e)
 {
     CHelper.RequireDataBind(false);
 }
Ejemplo n.º 18
0
 protected void Page_Load(object sender, EventArgs e)
 {
     ibClear.ImageUrl  = CHelper.GetAbsolutePath("/Images/IbnFramework/delete.gif");
     ibSelect.ImageUrl = CHelper.GetAbsolutePath("/Images/IbnFramework/search.gif");
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Internals the bind paging.
        /// </summary>
        private void internalBindPaging()
        {
            if (MainGrid.BottomPagerRow != null)
            {
                if (MainGrid.BottomPagerRow.FindControl("ddPaging") != null)
                {
                    DropDownList ddPaging = (DropDownList)MainGrid.BottomPagerRow.FindControl("ddPaging");

                    if (MainGrid.PageSize < 10000)
                    {
                        CHelper.SafeSelect(ddPaging, MainGrid.PageSize.ToString());
                    }
                    else
                    {
                        CHelper.SafeSelect(ddPaging, "-1");
                    }
                }

                if (MainGrid.BottomPagerRow.FindControl("tbCurrentPage") != null)
                {
                    TextBox     tb         = (TextBox)MainGrid.BottomPagerRow.FindControl("tbCurrentPage");
                    ImageButton btnRefresh = (ImageButton)MainGrid.BottomPagerRow.FindControl("btnRefresh");

                    tb.Attributes.Add("onkeypress", this.PagingJsOnKeyPressHandler(btnRefresh));
                    tb.Attributes.Add("autocomplete", "off");

                    int pageIndex = MainGrid.PageIndex + 1;
                    tb.Text = pageIndex.ToString();
                }

                if (MainGrid.PageIndex <= 0)
                {
                    ImageButton imgPrev = (ImageButton)MainGrid.BottomPagerRow.FindControl("ImageButtonPrevious");
                    imgPrev.CommandName   = "";
                    imgPrev.ImageUrl      = "~/Images/IbnFramework/page-prev-disabled.gif";
                    imgPrev.OnClientClick = "return false;";
                    ImageButton imgFirst = (ImageButton)MainGrid.BottomPagerRow.FindControl("ImageButtonFirst");
                    imgFirst.CommandName   = "";
                    imgFirst.ImageUrl      = "~/Images/IbnFramework/page-first-disabled.gif";
                    imgFirst.OnClientClick = "return false;";
                }

                if (MainGrid.PageIndex == MainGrid.PageCount - 1)
                {
                    ImageButton imgNext = (ImageButton)MainGrid.BottomPagerRow.FindControl("ImageButtonNext");
                    imgNext.CommandName   = "";
                    imgNext.ImageUrl      = "~/Images/IbnFramework/page-next-disabled.gif";
                    imgNext.OnClientClick = "return false;";
                    ImageButton imgLast = (ImageButton)MainGrid.BottomPagerRow.FindControl("ImageButtonLast");
                    imgLast.CommandName   = "";
                    imgLast.OnClientClick = "return false;";
                    imgLast.ImageUrl      = "~/Images/IbnFramework/page-last-disabled.gif";
                }

                if (MainGrid.PageCount == 1)
                {
                    HtmlGenericControl divPaging = (HtmlGenericControl)MainGrid.BottomPagerRow.FindControl("pagingContainer");
                    divPaging.Style.Add("display", "none");
                }
                else
                {
                    HtmlGenericControl divPaging = (HtmlGenericControl)MainGrid.BottomPagerRow.FindControl("pagingContainer");
                    divPaging.Style.Add("display", "block");
                }

                if (MainGrid.BottomPagerRow.FindControl("ltTotalElements") != null)
                {
                    Literal lt = (Literal)MainGrid.BottomPagerRow.FindControl("ltTotalElements");
                    lt.Text = String.Format("{0}.", this.Count.ToString());                     //CHelper.GetResFileString("{IbnFramework.Common:
                }
                if (MainGrid.BottomPagerRow.FindControl("ltTotalPage") != null)
                {
                    Literal ltPages = (Literal)MainGrid.BottomPagerRow.FindControl("ltTotalPage");
                    ltPages.Text = String.Format("{0}", MainGrid.PageCount);
                }
            }
        }
Ejemplo n.º 20
0
        public string GetJsonDataSource(string nodeId)
        {
            int parentId = 0;

            int.TryParse(nodeId, out parentId);

            List <JsonTreeNode> nodes = new List <JsonTreeNode>();

            JsonTreeNode node;

            if (parentId == 0)
            {
                ListFolder privFolder = ListManager.GetPrivateRoot(Mediachase.Ibn.Data.Services.Security.CurrentUserId);
                node = new JsonTreeNode();

                node.text = CHelper.GetResFileString("{IbnShell.Navigation:tPrivLists}");
                node.cls  = "nodeCls";

                node.id             = Guid.NewGuid().ToString("N");
                node.itemid         = privFolder.PrimaryKeyId.Value.ToString();
                node.staticParentId = _rootId;

                node.href       = "../../../Apps/ListApp/Pages/ListInfoList.aspx?ListFolderId=" + privFolder.PrimaryKeyId.Value.ToString();
                node.hrefTarget = "right";

                if (!privFolder.HasChildren)
                {
                    node.leaf = true;
                }

                nodes.Add(node);

                ListFolder pubFolder = ListManager.GetPublicRoot();
                node = new JsonTreeNode();

                node.text = CHelper.GetResFileString("{IbnShell.Navigation:tPubLists}");
                node.cls  = "nodeCls";

                node.id             = Guid.NewGuid().ToString("N");
                node.itemid         = pubFolder.PrimaryKeyId.Value.ToString();
                node.staticParentId = _rootId;

                node.href       = "../../../Apps/ListApp/Pages/ListInfoList.aspx?ListFolderId=" + pubFolder.PrimaryKeyId.Value.ToString();
                node.hrefTarget = "right";

                if (!pubFolder.HasChildren)
                {
                    node.leaf = true;
                }

                nodes.Add(node);

                if (Mediachase.IBN.Business.Configuration.ProjectManagementEnabled)
                {
                    node = new JsonTreeNode();

                    node.text = CHelper.GetResFileString("{IbnShell.Navigation:tPrjLists}");
                    node.cls  = "nodeCls";

                    node.id             = Guid.NewGuid().ToString("N");
                    node.itemid         = "-1";
                    node.staticParentId = _rootId;

                    node.href       = "../../../Apps/ListApp/Pages/ListInfoList.aspx?ListFolderId=-1";
                    node.hrefTarget = "right";

                    node.leaf = true;
                    nodes.Add(node);
                }
            }
            else
            {
                ListFolder fParent = new ListFolder(parentId);
                if (fParent != null)
                {
                    Mediachase.Ibn.Data.Services.TreeService ts = fParent.GetService <Mediachase.Ibn.Data.Services.TreeService>();
                    foreach (Mediachase.Ibn.Data.Services.TreeNode tN in ts.GetChildNodes())
                    {
                        MetaObject moFolder  = tN.InnerObject;
                        ListFolder folder    = new ListFolder(moFolder.PrimaryKeyId.Value);
                        int        iFolderId = folder.PrimaryKeyId.Value;

                        node = new JsonTreeNode();

                        node.text = folder.Title;
                        node.cls  = "nodeCls";

                        node.id             = Guid.NewGuid().ToString("N");
                        node.itemid         = iFolderId.ToString();
                        node.staticParentId = _rootId;

                        node.href       = "../../../Apps/ListApp/Pages/ListInfoList.aspx?ListFolderId=" + iFolderId.ToString();
                        node.hrefTarget = "right";

                        if (!folder.HasChildren)
                        {
                            node.leaf = true;
                        }

                        nodes.Add(node);
                    }
                }
            }

            if (nodes.Count > 0)
            {
                return(UtilHelper.JsonSerialize(nodes));
            }
            else
            {
                return(String.Empty);
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Gets the mapping source.
        /// </summary>
        /// <returns></returns>
        private DataTable GetMappingSource()
        {
            if (ViewState["_ir"] == null)
            {
                return(null);
            }
            _ir = (ImportRequest)ViewState["_ir"];

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("metaFieldName", typeof(string)));
            dt.Columns.Add(new DataColumn("metaField", typeof(string)));
            dt.Columns.Add(new DataColumn("column", typeof(string)));
            DataRow dr;

            MetaClass             mc  = MetaDataWrapper.GetMetaClassByName(_className);
            MappingElementBuilder meb = new MappingElementBuilder(_ir.MappingDocument);

            foreach (MetaField mf in mc.Fields)
            {
                if (mf.InPrimaryKey || mf.IsBackReference || mf.IsLink || mf.IsReferencedField ||
                    !SchemaAttribute.CheckIsUpdatable(mf))
                {
                    continue;
                }

                if (mf.IsAggregation)
                {
                    #region IsAggregation
                    string    aggrClassName = mf.Attributes.GetValue <string>(McDataTypeAttribute.AggregationMetaClassName);
                    MetaClass aggrClass     = MetaDataWrapper.GetMetaClassByName(aggrClassName);
                    foreach (MetaField aggrField in aggrClass.Fields)
                    {
                        if (aggrField.InPrimaryKey || aggrField.IsBackReference || aggrField.IsLink ||
                            aggrField.IsReferencedField ||
                            !SchemaAttribute.CheckIsUpdatable(mf) ||
                            aggrField.Attributes.ContainsKey(McDataTypeAttribute.AggregationMark))
                        {
                            continue;
                        }

                        dr = dt.NewRow();
                        string uniqName = String.Format("{0}.{1}", mf.Name, aggrField.Name);
                        dr["metaFieldName"] = uniqName;
                        dr["metaField"]     = CHelper.GetResFileString(aggrField.FriendlyName) + " (" + ((aggrField.GetOriginalMetaType() == null) ? aggrField.TypeName : CHelper.GetResFileString(aggrField.GetMetaType().FriendlyName)) + ")";

                        MappingRule mr = meb.GetRuleByMetaField(uniqName);

                        if (mr != null)
                        {
                            dr["column"] = mr.ColumnName;
                        }
                        else
                        {
                            dr["column"] = String.Empty;
                        }
                        dt.Rows.Add(dr);
                    }
                    #endregion

                    continue;
                }

                #region NonAggregation
                dr = dt.NewRow();
                dr["metaFieldName"] = mf.Name;
                dr["metaField"]     = CHelper.GetResFileString(mf.FriendlyName) + " (" + ((mf.GetOriginalMetaType() == null) ? mf.TypeName : CHelper.GetResFileString(mf.GetMetaType().FriendlyName)) + ")";

                MappingRule mr1 = meb.GetRuleByMetaField(mf.Name);

                if (mr1 != null)
                {
                    dr["column"] = mr1.ColumnName;
                }
                else
                {
                    dr["column"] = String.Empty;
                }

                dt.Rows.Add(dr);
                #endregion
            }
            return(dt);
        }
Ejemplo n.º 22
0
 public void ProcessMouseMove(int x, int y)
 {
     _ArrowLeftSelected  = CHelper.IsInBounds(RectArrowLeft, x, y) && _Selection > 0;
     _ArrowRightSelected = CHelper.IsInBounds(RectArrowRight, x, y) && _Selection < _ValueNames.Count - 1;
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Handles the ItemDataBound event of the dgMapping control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.DataGridItemEventArgs"/> instance containing the event data.</param>
        void dgMapping_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            DropDownList ddi = (DropDownList)e.Item.FindControl("ddColumns");

            if (ddi != null)
            {
                string mfName = e.Item.Cells[0].Text;

                #region Commented  may be needed
                //string ownFieldName = mfName;
                //string aggrFieldName = String.Empty;
                //string aggrClassName = String.Empty;
                //MetaClass ownClass = MetaDataWrapper.GetMetaClassByName(_className);
                //MetaClass aggrClass = null;
                //MetaField ownField = null;
                //MetaField aggrField = null;
                //if (ownFieldName.Contains("."))
                //{
                //    string[] mas = ownFieldName.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
                //    ownFieldName = mas[0];
                //    aggrFieldName = mas[1];
                //    ownField = MetaDataWrapper.GetMetaFieldByName(ownClass, ownFieldName);
                //    aggrClassName = ownField.Attributes.GetValue<string>(McDataTypeAttribute.AggregationMetaClassName);
                //    aggrField = MetaDataWrapper.GetMetaFieldByName(aggrClassName, aggrFieldName);
                //}
                //else
                //    ownField = MetaDataWrapper.GetMetaFieldByName(ownClass, ownFieldName);
                #endregion

                _ir = (ImportRequest)ViewState["_ir"];

                MetaField             field = FormController.GetMetaField(_className, mfName);
                MappingElementBuilder meb   = new MappingElementBuilder(_ir.MappingDocument);
                MappingRule           mr    = meb.GetRuleByMetaField(mfName);

                ddi.Items.Clear();
                ddi.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Common", "tNotSetValue").ToString(), "-1"));
                if (field.GetOriginalMetaType() != null)
                {
                    ddi.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Common", "tDefaultValue").ToString(), "0"));
                }

                foreach (DataColumn dc in _ir.Data.Tables[0].Columns)
                {
                    ddi.Items.Add(new ListItem(dc.ColumnName, dc.ColumnName));
                }

                string val = "-1";
                if (mr != null)
                {
                    if (mr.RuleType == MappingRuleType.DefaultValue)
                    {
                        val = "0";
                    }
                    else if (mr.RuleType == MappingRuleType.CopyValue)
                    {
                        val = mr.ColumnName;
                    }
                }
                CHelper.SafeSelect(ddi, val);

                TextBox      txt = (TextBox)e.Item.FindControl("tbColumn");
                DropDownList dd  = (DropDownList)e.Item.FindControl("ddColumn");
                switch (val)
                {
                case "-1":                              //Not Set
                    txt.Visible = false;
                    dd.Visible  = false;
                    break;

                case "0":                               //Default Value
                    if (field.IsEnum)
                    {
                        dd.Visible  = true;
                        txt.Visible = false;
                        dd.Items.Clear();
                        MetaFieldType mft = field.GetMetaType();
                        foreach (MetaEnumItem mei in mft.EnumItems)
                        {
                            dd.Items.Add(new ListItem(CHelper.GetResFileString(mei.Name), mei.Handle.ToString()));
                        }
                        if (!String.IsNullOrEmpty(mr.DefaultValue))
                        {
                            CHelper.SafeSelect(dd, mr.DefaultValue);
                        }
                    }
                    else if (field.IsReference)
                    {
                        dd.Visible  = true;
                        txt.Visible = false;
                        dd.Items.Clear();
                        string         refClassName = field.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceMetaClassName);
                        MetaClass      refClass     = MetaDataWrapper.GetMetaClassByName(refClassName);
                        EntityObject[] list         = BusinessManager.List(refClassName, (new FilterElementCollection()).ToArray());

                        dd.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Common", "tNotSetValue").ToString(), "-1"));
                        foreach (EntityObject eo in list)
                        {
                            dd.Items.Add(new ListItem(CHelper.GetResFileString(eo[refClass.TitleFieldName].ToString()), eo.PrimaryKeyId.Value.ToString()));
                        }
                        if (!String.IsNullOrEmpty(mr.DefaultValue))
                        {
                            CHelper.SafeSelect(dd, mr.DefaultValue);
                        }
                    }
                    else
                    {
                        dd.Visible  = false;
                        txt.Visible = true;
                        txt.Text    = mr.DefaultValue;
                    }
                    break;

                default:                                //CopyValue
                    txt.Visible = false;
                    dd.Visible  = false;
                    break;
                }

                //Update UpdatePanel with lbl & txt && dd (upValues)
                foreach (Control c in e.Item.Cells[3].Controls)
                {
                    if (c is UpdatePanel)
                    {
                        ((UpdatePanel)c).Update();
                    }
                }
            }
        }
Ejemplo n.º 24
0
        protected void grdMain_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            if (ViewState[this.ClientID + "_TypeName"] == null)
            {
                return;
            }

            MetaFieldType mft = DataContext.Current.MetaModel.RegisteredTypes[ViewState[this.ClientID + "_TypeName"].ToString()];

            int ItemId = int.Parse(e.CommandArgument.ToString());

            TextBox      tb      = (TextBox)e.Item.FindControl("txtName");
            DropDownList ddl     = (DropDownList)e.Item.FindControl("ddlOrder");
            CheckBox     cb      = (CheckBox)e.Item.FindControl("cbDefault");
            int          OrderId = int.Parse(ddl.SelectedValue);

            if (tb != null && tb.Text.Trim() != String.Empty)
            {
                if (ItemId > 0)
                {
                    //edit meta enum item
                    if (mft != null)
                    {
                        //exists meta enum type
                        MetaEnum.UpdateItem(mft, ItemId, tb.Text.Trim(), OrderId);
                        if (cb.Checked)
                        {
                            //add default value
                            string sDef = String.Empty;
                            if (ViewState[this.ClientID + "_IsDefaultId"] != null)
                            {
                                sDef = ViewState[this.ClientID + "_IsDefaultId"].ToString();
                            }
                            if (sDef != String.Empty)
                            {
                                sDef += ",";
                            }
                            sDef += ItemId.ToString();

                            ViewState[this.ClientID + "_IsDefaultId"] = sDef;
                        }
                        else
                        {
                            //remove default value
                            string sDef = String.Empty;
                            if (ViewState[this.ClientID + "_IsDefaultId"] != null)
                            {
                                sDef = ViewState[this.ClientID + "_IsDefaultId"].ToString();
                            }
                            string[]      mas = sDef.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                            List <string> lst = new List <string>(mas);
                            if (lst.Contains(ItemId.ToString()))
                            {
                                lst.Remove(ItemId.ToString());
                                ViewState[this.ClientID + "_IsDefaultId"] = String.Join(",", lst.ToArray());
                            }
                        }
                    }
                    else
                    {
                        //new meta enum type
                        DataTable dt       = ((DataTable)ViewState[this.ClientID + "_DataSource"]).Copy();
                        DataRow   drUpdate = null;
                        foreach (DataRow dr in dt.Rows)
                        {
                            if ((int)dr["Id"] == ItemId)
                            {
                                drUpdate = dr;
                                break;
                            }
                        }
                        if (drUpdate != null)
                        {
                            drUpdate["Name"]        = tb.Text.Trim();
                            drUpdate["DisplayName"] = CHelper.GetResFileString(tb.Text.Trim());
                            //ordering
                            int oldOrderId = (int)drUpdate["OrderId"];
                            foreach (DataRow dr in dt.Rows)
                            {
                                int curOrder = (int)dr["OrderId"];
                                if (oldOrderId > OrderId)
                                {
                                    if (curOrder >= OrderId && curOrder < oldOrderId)
                                    {
                                        dr["OrderId"] = curOrder + 1;
                                    }
                                }
                                else
                                {
                                    if (curOrder > oldOrderId && curOrder <= OrderId)
                                    {
                                        dr["OrderId"] = curOrder - 1;
                                    }
                                }
                            }
                            drUpdate["OrderId"]   = OrderId;
                            drUpdate["IsDefault"] = cb.Checked;
                        }
                        ViewState[this.ClientID + "_DataSource"] = dt;
                    }
                }
                else
                {
                    //add meta enum item
                    if (mft != null)
                    {
                        //exists meta enum type
                        int id = MetaEnum.AddItem(mft, tb.Text.Trim(), OrderId);
                        if (cb.Checked)
                        {
                            //add default value
                            string sDef = String.Empty;
                            if (ViewState[this.ClientID + "_IsDefaultId"] != null)
                            {
                                sDef = ViewState[this.ClientID + "_IsDefaultId"].ToString();
                            }
                            if (sDef != String.Empty)
                            {
                                sDef += ",";
                            }
                            sDef += id.ToString();

                            ViewState[this.ClientID + "_IsDefaultId"] = sDef;
                        }
                        else
                        {
                            //remove default value
                            string sDef = String.Empty;
                            if (ViewState[this.ClientID + "_IsDefaultId"] != null)
                            {
                                sDef = ViewState[this.ClientID + "_IsDefaultId"].ToString();
                            }
                            string[]      mas = sDef.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                            List <string> lst = new List <string>(mas);
                            if (lst.Contains(id.ToString()))
                            {
                                lst.Remove(id.ToString());
                                ViewState[this.ClientID + "_IsDefaultId"] = String.Join(",", lst.ToArray());
                            }
                        }
                    }
                    else
                    {
                        //new meta enum type
                        DataTable dt = ((DataTable)ViewState[this.ClientID + "_DataSource"]).Copy();
                        int       id = 0;
                        //id & ordering definition
                        foreach (DataRow dr in dt.Rows)
                        {
                            if ((int)dr["Id"] >= id)
                            {
                                id = (int)dr["Id"];
                            }
                            if ((int)dr["OrderId"] >= OrderId)
                            {
                                dr["OrderId"] = (int)dr["OrderId"] + 1;
                            }
                        }
                        id = id + 1;
                        DataRow drNew = dt.NewRow();
                        drNew["Id"]          = id;
                        drNew["OrderId"]     = OrderId;
                        drNew["Name"]        = tb.Text.Trim();
                        drNew["DisplayName"] = CHelper.GetResFileString(tb.Text.Trim());
                        drNew["IsDefault"]   = cb.Checked;
                        dt.Rows.Add(drNew);
                        ViewState[this.ClientID + "_DataSource"] = dt;
                    }
                }
            }

            grdMain.EditItemIndex = -1;
            BindGrid(GetDataTable());
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Handles the ActiveStepChanged event of the ucWizard control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void ucWizard_ActiveStepChanged(object sender, EventArgs e)
        {
            //step1
            if (ucWizard.ActiveStep.ID == "step1")
            {
                ViewState["_ir"] = null;
            }

            //step2
            if (ucWizard.ActiveStep.ID == "step3")
            {
                #region upload file
                if (fSourceFile.PostedFile != null && fSourceFile.PostedFile.ContentLength > 0)
                {
                    ProcessFileCache(Server.MapPath(Mediachase.UI.Web.Util.CommonHelper.ChartPath));
                    String dir     = Mediachase.UI.Web.Util.CommonHelper.ChartPath;
                    string wwwpath = dir + Guid.NewGuid().ToString("N");
                    wwwpath += Path.GetExtension(fSourceFile.PostedFile.FileName);

                    hdnFilePath.Value = wwwpath;
                    using (Stream sw = File.Create(Server.MapPath(wwwpath)))
                    {
                        fSourceFile.PostedFile.InputStream.Seek(0, SeekOrigin.Begin);
                        System.IO.BinaryReader br = new System.IO.BinaryReader(fSourceFile.PostedFile.InputStream);
                        int    iBufferSize        = 655360;               // 640 KB
                        byte[] outbyte            = br.ReadBytes(iBufferSize);

                        while (outbyte.Length > 0)
                        {
                            sw.Write(outbyte, 0, outbyte.Length);
                            outbyte = br.ReadBytes(iBufferSize);
                        }
                        br.Close();
                    }
                }
                #endregion

                divCSV.Visible = (rbSourceType.SelectedIndex == 2);

                #region file parsing
                IIncomingDataParser parser  = null;
                DataSet             rawData = null;
                try
                {
                    switch (rbSourceType.SelectedIndex)
                    {
                    case 0:
                        IMCOleDBHelper helper = (IMCOleDBHelper)Activator.GetObject(typeof(IMCOleDBHelper), ConfigurationManager.AppSettings["McOleDbServiceString"]);
                        rawData = helper.ConvertExcelToDataSet(Server.MapPath(hdnFilePath.Value));
                        break;

                    case 1:
                        parser  = new XmlIncomingDataParser();
                        rawData = parser.Parse(Server.MapPath(hdnFilePath.Value), null);
                        break;

                    case 2:
                        rawData = GetRawDataForCSV();
                        break;

                    case 3:
                        rawData = VCardUtil.ConvertFile(Server.MapPath(hdnFilePath.Value));
                        break;
                    }
                }
                catch (Exception ex)
                {
                    CHelper.GenerateErrorReport(ex);
                    ViewState["ServiceError"]  = true;
                    ViewState["ErrorFileName"] = Server.MapPath(hdnFilePath.Value);
                    ucWizard.MoveTo(this.step4);
                    return;
                }
                #endregion

                if (ViewState["_ir"] == null)
                {
                    InitializeMappingDocumentRequest  imdr = new InitializeMappingDocumentRequest(_className, rawData, 0);
                    InitializeMappingDocumentResponse resp = (InitializeMappingDocumentResponse)BusinessManager.Execute(imdr);
                    MappingDocument md = resp.MappingDocument;
                    _ir = new ImportRequest(_className, rawData, md);
                    ViewState["_ir"] = _ir;
                }
                BindDG();
            }

            if (ucWizard.ActiveStep.ID == "step4")
            {
                if (ViewState["ServiceError"] != null && (bool)ViewState["ServiceError"])
                {
                    string fileName = ViewState["ErrorFileName"].ToString();
                    if (fileName.EndsWith("xlsx") && !Is2007OfficeSystemDriverInstalled(fileName))
                    {
                        lblResult.Text = GetGlobalResourceObject("IbnFramework.Common", "McOleDbServiceWarningXlsx").ToString();
                    }
                    else
                    {
                        lblResult.Text = GetGlobalResourceObject("IbnFramework.Common", "McOleDbServiceWarning").ToString();
                    }
                }
                foreach (Control c in ucWizard.ActiveStep.Controls)
                {
                    if (c is Button)
                    {
                        Button btn   = (Button)c;
                        string param = String.Empty;
                        if (!String.IsNullOrEmpty(_commandName))
                        {
                            param = (new CommandParameters(_commandName)).ToString();
                        }
                        string script = Mediachase.Ibn.Web.UI.WebControls.CommandHandler.GetCloseOpenedFrameScript(this.Page, param);
                        script           += " return false;";
                        btn.OnClientClick = script;
                    }
                }
            }
        }
Ejemplo n.º 26
0
        protected override void OnPreRender(EventArgs e)
        {
            _pc["EntityList_" + ClassName + "_" + _profileName + "_PageIndex"] = grdMain.PageIndex.ToString();

            //кнопка очистить фильтр у key-textbox
            btnClear.Visible = !String.IsNullOrEmpty(txtSearch.Text);

            //стиль key-textbox
            txtSearch.BorderWidth = 1;
            txtSearch.BorderStyle = BorderStyle.Solid;
            txtSearch.Style.Add(HtmlTextWriterStyle.Padding, "2px");
            txtSearch.BorderColor = Color.FromArgb(127, 157, 185);
            txtSearch.BackColor   = (!String.IsNullOrEmpty(txtSearch.Text)) ? Color.FromArgb(255, 240, 144) : Color.White;

            //если необходимо перебиндить датагрид
            if (CHelper.NeedToBindGrid())
            {
                //если кто-то где-то изменил значение quickfilter с ролью - надо перезагрузить вид
                if (String.Compare(_profileName, ddProfiles.SelectedValue, true) != 0)
                {
                    this.Page.Response.Redirect(this.Page.Request.RawUrl, true);
                    return;
                }
                //биндим датагрид
                BindDataGrid(true);
                //обновляем UpdatePanel грида
                grdMainPanel.Update();
            }

            //собираем текст FilterView
            string sText = String.Empty;

            if (!String.IsNullOrEmpty(_filterText))
            {
                sText = _filterText;
            }
            else
            {
                if (_isFilterSet)
                {
                    sText = GetGlobalResourceObject("IbnFramework.Global", "FilterIsSet").ToString();
                }
                else
                {
                    sText = GetGlobalResourceObject("IbnFramework.Global", "FilterIsNotSet").ToString();
                }
            }
            FilterIsSet.ForeColor = Color.FromArgb(0x90, 0x90, 0x90);
            FilterIsSet.Text      = sText;

            int currentUserId = Mediachase.Ibn.Data.Services.Security.CurrentUserId;

            //в случае, если отображаемый набор фильтров создан текущим пользователем - он может его удалить
            //генерируем imagebutton справа от набора фильтров
            ibDeleteInfo.ToolTip = GetGlobalResourceObject("IbnFramework.Incident", "_mc_DeleteView").ToString();
            ibDeleteInfo.Attributes.Add("onclick", String.Format("return confirm('{0}');", GetGlobalResourceObject("IbnFramework.Incident", "_mc_DeleteViewWarning").ToString()));
            ibDeleteInfo.Visible = Mediachase.Ibn.Core.ListViewProfile.CanDelete(ClassName, ddProfiles.SelectedValue, _placeName, currentUserId);

            ibEditInfo.ToolTip = GetGlobalResourceObject("IbnFramework.Common", "Edit").ToString();
            CommandManager    cm = CommandManager.GetCurrent(this.Page);
            CommandParameters cp = new CommandParameters("MC_MUI_ProfileEdit");

            cp.CommandArguments = new Dictionary <string, string>();
            cp.AddCommandArgument("ClassName", ClassName);
            cp.AddCommandArgument("uid", ddProfiles.SelectedValue);
            string scriptEdit = cm.AddCommand(ClassName, ViewName, _placeName, cp);

            ibEditInfo.Attributes.Add("onclick", String.Format("javascript:{{{0};return false;}}", scriptEdit));
            ibEditInfo.Visible = Mediachase.Ibn.Core.ListViewProfile.CanDelete(ClassName, ddProfiles.SelectedValue, _placeName, currentUserId);


            cp = new CommandParameters("MC_MUI_ProfileNew");
            cp.CommandArguments = new Dictionary <string, string>();
            cp.AddCommandArgument("ClassName", ClassName);
            scriptEdit       = cm.AddCommand(ClassName, ViewName, _placeName, cp);
            scriptEdit       = scriptEdit.Replace("\"", "&quot;");
            AddNewViewScript = scriptEdit;

            hfFilterValue.Value = ddProfiles.SelectedValue;

            // Printer Varsion
            if (CHelper.GetFromContext(CHelper.PrinterVersionKey) != null &&
                (bool)CHelper.GetFromContext(CHelper.PrinterVersionKey))
            {
                CHelper.PrintControl(PrepareExportGrid(), CHelper.GetResFileString(mc.PluralName), this.Page);
                dgExport.Visible = false;
            }

            base.OnPreRender(e);
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "main_js", "<script language=\"javascript\" type=\"text/javascript\" src=\"" + CHelper.GetAbsolutePath("/Apps/MetaDataBase/Scripts/main.js") + "\"></script>");
     Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "common_js", "<script language=\"javascript\" type=\"text/javascript\" src=\"" + CHelper.GetAbsolutePath("/Apps/MetaDataBase/Scripts/common.js") + "\"></script>");
 }
Ejemplo n.º 28
0
        private void BindGroupDataList()
        {
            //заполняем левый даталист для группировок
            if (!String.IsNullOrEmpty(lvp.GroupByFieldName))
            {
                string groupField = lvp.GroupByFieldName;

                if (mc != null && mc.Fields.Contains(groupField))
                {
                    MetaField mf = mc.Fields[groupField];
                    if (mf.IsEnum)
                    {
                        DataTable dt = new DataTable();
                        dt.Columns.Add(new DataColumn("Id", typeof(int)));
                        dt.Columns.Add(new DataColumn("Name", typeof(string)));

                        foreach (MetaEnumItem item in MetaEnum.GetItems(mf.GetMetaType()))
                        {
                            DataRow row = dt.NewRow();
                            row["Id"]   = item.Handle;
                            row["Name"] = CHelper.GetResFileString(item.Name);
                            dt.Rows.Add(row);
                        }

                        DataView dv = dt.DefaultView;
                        dv.Sort = "Name";

                        groupList.DataSource   = dv;
                        groupList.DataKeyField = "Id";
                        groupList.DataBind();

                        //пытаемся найти и выделить последнюю запомненную группу
                        int selectedIndex = 0;
                        if (_pc[ViewName + "_" + groupField + "_" + GroupItemKey] != null)
                        {
                            foreach (DataListItem dli in groupList.Items)
                            {
                                LinkButton lb = (LinkButton)dli.FindControl("lbGroupItem");
                                if (lb != null && lb.CommandArgument == _pc[ViewName + "_" + groupField + "_" + GroupItemKey])
                                {
                                    selectedIndex = dli.ItemIndex;
                                    break;
                                }
                            }
                        }

                        if (groupList.Items.Count > 0)
                        {
                            groupList.SelectedIndex = selectedIndex;
                        }

                        //сохраняем выделенное значением _pc
                        if (groupList.SelectedValue != null)
                        {
                            _pc[ViewName + "_" + groupField + "_" + GroupItemKey] = groupList.SelectedValue.ToString();
                        }
                        else
                        {
                            _pc[ViewName + "_" + groupField + "_" + GroupItemKey] = "0";
                        }
                    }
                }
            }
        }
Ejemplo n.º 29
0
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp            = (CommandParameters)Element;
                string[]          elemsToDelete = MCGrid.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]);

                int error = 0;
                using (DbTransaction tran = DbTransaction.Begin())
                {
                    foreach (string elem in elemsToDelete)
                    {
                        int id = Convert.ToInt32(elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0], CultureInfo.InvariantCulture);
                        if (id > 0)
                        {
                            try
                            {
                                ToDo.Delete(id);
                            }
                            catch (AccessDeniedException)
                            {
                                error++;
                            }
                        }
                    }
                    tran.Commit();
                }
                if (error > 0)
                {
                    ClientScript.RegisterStartupScript(((Control)Sender).Page, ((Control)Sender).Page.GetType(), Guid.NewGuid().ToString("N"),
                                                       String.Format("alert('{0}');", CHelper.GetResFileString("{IbnFramework.ListInfo:RefItemException}")), true);
                }

                CHelper.RequireBindGrid();
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Loads all cover-themes to list.
        /// </summary>
        private static void LoadCoverThemes()
        {
            _CoverThemes.Clear();

            CHelper Helper = new CHelper();
            string path = CSettings.sFolderCover;
            List<string> files = Helper.ListFiles(path, "*.xml", false);

            foreach (string file in files)
            {
                bool loaded = false;
                XPathDocument xPathDoc = null;
                XPathNavigator navigator = null;

                try
                {
                    xPathDoc = new XPathDocument(Path.Combine(path, file));
                    navigator = xPathDoc.CreateNavigator();
                    loaded = true;
                }
                catch (Exception)
                {
                    loaded = false;
                    if (navigator != null)
                        navigator = null;

                    if (xPathDoc != null)
                        xPathDoc = null;
                }

                if (loaded)
                {
                    SCoverTheme coverTheme = new SCoverTheme();

                    CHelper.GetValueFromXML("//root/Info/Name", navigator, ref coverTheme.Name, String.Empty);
                    CHelper.GetValueFromXML("//root/Info/Folder", navigator, ref coverTheme.Folder, String.Empty);

                    if (coverTheme.Folder != String.Empty && coverTheme.Name != String.Empty)
                    {
                        coverTheme.File = file;

                        _CoverThemes.Add(coverTheme);
                    }
                }
            }
        }
Ejemplo n.º 31
0
        public bool LoadTheme(string XmlPath, string ElementName, XPathNavigator navigator, int SkinIndex)
        {
            string item = XmlPath + "/" + ElementName;

            _ThemeLoaded = true;

            _ThemeLoaded &= CHelper.GetValueFromXML(item + "/CoverBackground", navigator, ref _Theme.CoverBackgroundName, String.Empty);
            _ThemeLoaded &= CHelper.GetValueFromXML(item + "/CoverBigBackground", navigator, ref _Theme.CoverBigBackgroundName, String.Empty);
            _ThemeLoaded &= CHelper.GetValueFromXML(item + "/DuetIcon", navigator, ref _Theme.DuetIconName, String.Empty);
            _ThemeLoaded &= CHelper.GetValueFromXML(item + "/VideoIcon", navigator, ref _Theme.VideoIconName, String.Empty);
            _ThemeLoaded &= CHelper.GetValueFromXML(item + "/MedleyCalcIcon", navigator, ref _Theme.MedleyCalcIcon, String.Empty);
            _ThemeLoaded &= CHelper.GetValueFromXML(item + "/MedleyTagIcon", navigator, ref _Theme.MedleyTagIcon, String.Empty);

            if (CHelper.GetValueFromXML(item + "/Color", navigator, ref _Theme.ColorName, String.Empty))
            {
                _ThemeLoaded &= CTheme.GetColor(_Theme.ColorName, SkinIndex, ref _Color);
            }
            else
            {
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/R", navigator, ref _Color.R);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/G", navigator, ref _Color.G);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/B", navigator, ref _Color.B);
                _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/A", navigator, ref _Color.A);
            }

            #region SongMenuTileBoard
            _ThemeLoaded &= CHelper.TryGetIntValueFromXML(item + "/SongMenuTileBoard/NumW", navigator, ref _Theme.songMenuTileBoard.numW);
            _ThemeLoaded &= CHelper.TryGetIntValueFromXML(item + "/SongMenuTileBoard/NumH", navigator, ref _Theme.songMenuTileBoard.numH);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SongMenuTileBoard/SpaceW", navigator, ref _Theme.songMenuTileBoard.spaceW);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SongMenuTileBoard/SpaceH", navigator, ref _Theme.songMenuTileBoard.spaceH);

            _ThemeLoaded &= CHelper.TryGetIntValueFromXML(item + "/SongMenuTileBoard/NumWsmall", navigator, ref _Theme.songMenuTileBoard.numWsmall);
            _ThemeLoaded &= CHelper.TryGetIntValueFromXML(item + "/SongMenuTileBoard/NumHsmall", navigator, ref _Theme.songMenuTileBoard.numHsmall);

            _ThemeLoaded &= _Theme.songMenuTileBoard.TextArtist.LoadTheme(item + "/SongMenuTileBoard", "TextArtist", navigator, SkinIndex);
            _ThemeLoaded &= _Theme.songMenuTileBoard.TextTitle.LoadTheme(item + "/SongMenuTileBoard", "TextTitle", navigator, SkinIndex);
            _ThemeLoaded &= _Theme.songMenuTileBoard.TextSongLength.LoadTheme(item + "/SongMenuTileBoard", "TextSongLength", navigator, SkinIndex);

            _ThemeLoaded &= _Theme.songMenuTileBoard.StaticCoverBig.LoadTheme(item + "/SongMenuTileBoard", "StaticCoverBig", navigator, SkinIndex);
            _ThemeLoaded &= _Theme.songMenuTileBoard.StaticTextBG.LoadTheme(item + "/SongMenuTileBoard", "StaticTextBG", navigator, SkinIndex);
            _ThemeLoaded &= _Theme.songMenuTileBoard.StaticDuetIcon.LoadTheme(item + "/SongMenuTileBoard", "StaticDuetIcon", navigator, SkinIndex);
            _ThemeLoaded &= _Theme.songMenuTileBoard.StaticVideoIcon.LoadTheme(item + "/SongMenuTileBoard", "StaticVideoIcon", navigator, SkinIndex);
            _ThemeLoaded &= _Theme.songMenuTileBoard.StaticMedleyCalcIcon.LoadTheme(item + "/SongMenuTileBoard", "StaticMedleyCalcIcon", navigator, SkinIndex);
            _ThemeLoaded &= _Theme.songMenuTileBoard.StaticMedleyTagIcon.LoadTheme(item + "/SongMenuTileBoard", "StaticMedleyTagIcon", navigator, SkinIndex);

            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SongMenuTileBoard/TileRectX", navigator, ref _Theme.songMenuTileBoard.TileRect.X);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SongMenuTileBoard/TileRectY", navigator, ref _Theme.songMenuTileBoard.TileRect.Y);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SongMenuTileBoard/TileRectZ", navigator, ref _Theme.songMenuTileBoard.TileRect.Z);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SongMenuTileBoard/TileRectW", navigator, ref _Theme.songMenuTileBoard.TileRect.W);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SongMenuTileBoard/TileRectH", navigator, ref _Theme.songMenuTileBoard.TileRect.H);

            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SongMenuTileBoard/TileRectSmallX", navigator, ref _Theme.songMenuTileBoard.TileRectSmall.X);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SongMenuTileBoard/TileRectSmallY", navigator, ref _Theme.songMenuTileBoard.TileRectSmall.Y);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SongMenuTileBoard/TileRectSmallZ", navigator, ref _Theme.songMenuTileBoard.TileRectSmall.Z);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SongMenuTileBoard/TileRectSmallW", navigator, ref _Theme.songMenuTileBoard.TileRectSmall.W);
            _ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/SongMenuTileBoard/TileRectSmallH", navigator, ref _Theme.songMenuTileBoard.TileRectSmall.H);

            #endregion SongMenuTileBoard

            if (_ThemeLoaded)
            {
                _Theme.Name = ElementName;
                LoadTextures();
                Init();
            }

            return(_ThemeLoaded);
        }
Ejemplo n.º 32
0
        public static void ListSkins()
        {
            CHelper Helper = new CHelper();
            int themeIndex = GetThemeIndex();
            _Skins.Clear();

            if (themeIndex < 0)
            {
                CLog.LogError("Error List Skins. Can't find Theme: " + CConfig.Theme);
                return;
            }

            Theme theme = _Themes[themeIndex];

            string path = Path.Combine(theme.Path, theme.SkinFolder);
            List<string> files = Helper.ListFiles(path, "*.xml", false);

            foreach (string file in files)
            {
                bool loaded = false;
                XPathDocument xPathDoc = null;
                XPathNavigator navigator = null;

                try
                {
                    xPathDoc = new XPathDocument(Path.Combine(path, file));
                    navigator = xPathDoc.CreateNavigator();
                    loaded = true;
                }
                catch (Exception e)
                {
                    CLog.LogError("Error loading skin " + file + ": " + e.Message);
                    loaded = false;
                    if (navigator != null)
                        navigator = null;

                    if (xPathDoc != null)
                        xPathDoc = null;
                }

                if (loaded)
                {
                    Skin skin = new Skin();

                    int version = 0;
                    CHelper.TryGetIntValueFromXML("//root/SkinSystemVersion", navigator, ref version);

                    if (version == SkinSystemVersion)
                    {
                        CHelper.GetValueFromXML("//root/Info/Name", navigator, ref skin.Name, String.Empty);
                        if (skin.Name != String.Empty)
                        {
                            CHelper.GetValueFromXML("//root/Info/Author", navigator, ref skin.Author, String.Empty);
                            CHelper.TryGetIntValueFromXML("//root/Info/SkinVersionMajor", navigator, ref skin.SkinVersionMajor);
                            CHelper.TryGetIntValueFromXML("//root/Info/SkinVersionMinor", navigator, ref skin.SkinVersionMinor);

                            skin.Path = path;
                            skin.FileName = file;

                            skin.SkinList = new List<SkinElement>();
                            List<string> names = CHelper.GetValuesFromXML("Skins", navigator);
                            foreach (string str in names)
                            {
                                SkinElement sk = new SkinElement();
                                sk.Name = str;
                                sk.Value = String.Empty;
                                skin.SkinList.Add(sk);
                            }

                            skin.VideoList = new List<SkinElement>();
                            names = CHelper.GetValuesFromXML("Videos", navigator);
                            foreach (string str in names)
                            {
                                SkinElement sk = new SkinElement();
                                sk.Name = str;
                                sk.Value = String.Empty;
                                skin.VideoList.Add(sk);
                            }
                            _Skins.Add(skin);
                        }
                    }
                    else
                    {
                        string msg = "Can't load Skin \"" + file + "\", ";
                        if (version < SkinSystemVersion)
                            msg += "the file ist outdated! ";
                        else
                            msg += "the file is for newer program versions! ";

                        msg += "Current SkinSystemVersion is " + SkinSystemVersion.ToString();
                        CLog.LogError(msg);
                    }
                }
            }
        }
Ejemplo n.º 33
0
        public override int DeleteData(int rc)
        {
            int rCount = CHelper.DeleteSelectedItems(itemSources, OnixWebServiceAPI.DeleteUser, rc.ToString());

            return(rCount);
        }
Ejemplo n.º 34
0
        private void CheckFiles()
        {
            CHelper Helper = new CHelper();

            if(this.CoverFileName == String.Empty){
                List<string> files = Helper.ListFiles(this.Folder, "*.jpg", false);
                files.AddRange(Helper.ListFiles(this.Folder, "*.png", false));
                foreach(String file in files)
                {
                    if (Regex.IsMatch(file, @".[CO].", RegexOptions.IgnoreCase) && (Regex.IsMatch(file, @"" + Regex.Escape(this.Title), RegexOptions.IgnoreCase) || Regex.IsMatch(file, @"" + Regex.Escape(this.Artist), RegexOptions.IgnoreCase)))
                    {
                        this.CoverFileName = file;
                    }
                }
            }

            if (this.BackgroundFileName == String.Empty)
            {
                List<string> files = Helper.ListFiles(this.Folder, "*.jpg", false);
                files.AddRange(Helper.ListFiles(this.Folder, "*.png", false));
                foreach (String file in files)
                {

                    if (Regex.IsMatch(file, @".[BG].", RegexOptions.IgnoreCase) && (Regex.IsMatch(file, @"" + Regex.Escape(this.Title), RegexOptions.IgnoreCase) || Regex.IsMatch(file, @"" + Regex.Escape(this.Artist), RegexOptions.IgnoreCase)))
                    {
                        this.BackgroundFileName = file;
                    }
                }
            }
        }
Ejemplo n.º 35
0
        private void BindDataN1()
        {
            PrimaryObjectLink.Visible = false;
            PrimaryObjectList.Visible = true;
            RelatedObjectLink.Visible = true;
            RelatedObjectList.Visible = false;

            RelatedObjectLink.Text        = CHelper.GetResFileString(mc.FriendlyName);
            RelatedObjectLink.NavigateUrl = String.Format(CultureInfo.InvariantCulture,
                                                          "{0}?class={1}&Tab=RelN1", ReturnUrl, ClassName);

            if (mf == null)             // new N:1
            {
                FillObjectList(PrimaryObjectList);
                RebindFieldInfoByPrimaryObject();
                RebindDisplayInfo(PrimaryObjectList.SelectedValue);

                mfs.BindData(ClassName);
                if (mfs.Count == 0)
                {
                    FormsRow.Visible = false;
                }

                // Display Block
                DisplayText.Text = CHelper.GetResFileString(mc.PluralName);
            }
            else             // edit N:1
            {
                string    primaryClassName = mf.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceMetaClassName, string.Empty);
                MetaClass primaryClass     = MetaDataWrapper.GetMetaClassByName(primaryClassName);
                PrimaryObjectList.Items.Add(new ListItem(CHelper.GetResFileString(primaryClass.FriendlyName), primaryClassName));
                PrimaryObjectList.Enabled = false;

                // Field Block
                NameTextBox.Text    = mf.Name;
                NameTextBox.Enabled = false;

                FriendlyNameTextBox.Text = mf.FriendlyName;

                AllowNullsCheckBox.Checked = mf.IsNullable;
                AllowNullsCheckBox.Enabled = false;

                FormsRow.Visible = false;

                // Display Block
                RebindDisplayInfo(primaryClassName);

                CHelper.SafeSelect(DisplayRegion, mf.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceDisplayBlock, notSetValue));
                DisplayText.Text      = mf.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceDisplayText, CHelper.GetResFileString(mc.PluralName));
                DisplayOrderText.Text = mf.Attributes.GetValue <string>(McDataTypeAttribute.ReferenceDisplayOrder, "10000");
                if (DisplayRegion.SelectedValue == notSetValue)
                {
                    DisplayTextRow.Visible  = false;
                    DisplayOrderRow.Visible = false;
                }
                else
                {
                    DisplayTextRow.Visible  = true;
                    DisplayOrderRow.Visible = true;
                }
            }

            FieldBlockHeader.Title = String.Format(CultureInfo.InvariantCulture,
                                                   "{0} \"{1}\"",
                                                   GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Object"),
                                                   CHelper.GetResFileString(mc.FriendlyName));

            MainBlockHeader.Title = GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "RelationN1").ToString();

            CancelButton.Attributes.Add("onclick",
                                        String.Format(CultureInfo.InvariantCulture,
                                                      "window.location.href='{0}?class={1}&Tab=RelN1'; return false;",
                                                      ResolveClientUrl(ReturnUrl),
                                                      ClassName));
        }