Example #1
0
        public static TProfile LoadCurrentProfile <TProfile>()
            where TProfile : TestProfileBase, new()
        {
            TProfile result = null;

            var className = typeof(TProfile).Name;
            var machineProfileFileName = string.Format(@"SPMetaRegressionProfiles/{0}.{1}.xml", Environment.MachineName, className);

            if (File.Exists(machineProfileFileName))
            {
                // pragmatic way
                var profileXml = File
                                 .ReadAllText(machineProfileFileName)
                                 .Replace("{$MachineName$}", Environment.MachineName);

                result = XmlSerializerUtils.DeserializeFromString <TProfile>(profileXml);
            }

            if (result != null)
            {
                return(result);
            }

            return(new TProfile());
        }
        public static T GetConfig <T>() where T : class, ISetting
        {
            string filePath = GetFilePath(typeof(T));
            T      setting  = null;

            if (File.Exists(filePath))
            {
                string cacheKey = "common_classify_setting_" + typeof(T).Name;
                setting = HttpRuntime.Cache.Get(cacheKey) as T;

                if (setting == null)
                {
                    lock (GetLock(typeof(T)))
                    {
                        setting = XmlSerializerUtils.Deserialize <T>(filePath);
                        if (setting != null)
                        {
                            HttpRuntime.Cache.Insert(cacheKey, setting, new CacheDependency(filePath));
                        }
                    }
                }
            }

            return(setting);
        }
Example #3
0
        public static NodeUpdateStatus Update(NodeInfo node)
        {
            NodeInfo dataById = Node.GetDataById(node.AutoID);

            node.Setting = XmlSerializerUtils.Serialize <NodeSetting>(node.NodeSetting);
            int num = Node.ExistsNode(node.ParentID, node.NodeName, node.UrlRewriteName, "Modify", dataById.AutoID);
            NodeUpdateStatus result;

            if (num > 0)
            {
                result = (NodeUpdateStatus)num;
            }
            else if (!dataById.IsShowOnMenu && node.IsShowOnMenu && Node.GetMainNodeCount() >= Ver.GetVer().NodeLimit)
            {
                result = NodeUpdateStatus.ToMoreNode;
            }
            else if (BizBase.dbo.UpdateModel <NodeInfo>(node))
            {
                CacheUtils.Del("JsonLeeCMS_CacheForGetCMSNode");
                result = NodeUpdateStatus.Success;
            }
            else
            {
                CacheUtils.Del("JsonLeeCMS_CacheForGetCMSNode");
                result = NodeUpdateStatus.Error;
            }
            return(result);
        }
Example #4
0
        public DynamicSetting()
        {
            string fileName = this.GetType().Name;

            _fileDir = HttpContext.Current != null
                             ? HttpContext.Current.Server.MapPath("~/" + ConfigPath + "/")
                             : AppDomain.CurrentDomain.BaseDirectory + "/" + ConfigPath + "/";

            _filePath = _fileDir + fileName + ".config";

            if (File.Exists(_filePath))
            {
                string cacheKey = "common_dynamic_setting";
                _innerSettings = HttpRuntime.Cache.Get(cacheKey) as List <ItemPair>;

                if (_innerSettings == null)
                {
                    lock (_syncRoot)
                    {
                        _innerSettings = XmlSerializerUtils.Deserialize <List <ItemPair> >(_filePath);

                        if (_innerSettings != null)
                        {
                            HttpRuntime.Cache.Insert(cacheKey, _innerSettings, new CacheDependency(_filePath));
                        }
                    }
                }
            }

            if (_innerSettings == null)
            {
                _innerSettings = new List <ItemPair>();
            }
        }
Example #5
0
 protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
     {
         ContFieldInfo contFieldInfo = e.Item.DataItem as ContFieldInfo;
         FieldControl  fieldControl  = e.Item.FindControl("field") as FieldControl;
         if (fieldControl != null)
         {
             fieldControl.ControlType   = (FieldType)contFieldInfo.FieldType;
             fieldControl.ControlPath   = "~/Platform/h5/FieldControls/";
             fieldControl.LoadControlId = ((FieldType)contFieldInfo.FieldType).ToString();
             fieldControl.FieldName     = contFieldInfo.FieldName;
             fieldControl.FieldAlias    = contFieldInfo.Alias;
             fieldControl.Tips          = contFieldInfo.Tip;
             fieldControl.FieldId       = contFieldInfo.AutoID;
             fieldControl.Settings      = XmlSerializerUtils.Deserialize <SinGooCMS.Control.FieldSetting>(contFieldInfo.Setting);
             fieldControl.DataLength    = contFieldInfo.DataLength;
             fieldControl.EnableNull    = contFieldInfo.EnableNull;
             if (!string.IsNullOrEmpty(contFieldInfo.Value))
             {
                 fieldControl.Value = contFieldInfo.Value;
             }
             else
             {
                 fieldControl.Value = (contFieldInfo.DefaultValue ?? string.Empty);
             }
             if (!base.IsEdit && fieldControl.FieldName == "Sort")
             {
                 fieldControl.Value = (SinGooCMS.BLL.Content.MaxSort + 1).ToString();
             }
         }
     }
 }
Example #6
0
 protected void rptDetail_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
     {
         ProductFieldInfo productFieldInfo = e.Item.DataItem as ProductFieldInfo;
         FieldControl     fieldControl     = e.Item.FindControl("field") as FieldControl;
         if (fieldControl != null)
         {
             fieldControl.ControlType   = (FieldType)productFieldInfo.FieldType;
             fieldControl.ControlPath   = "~/Platform/h5/FieldControls/";
             fieldControl.LoadControlId = ((FieldType)productFieldInfo.FieldType).ToString();
             fieldControl.FieldName     = productFieldInfo.FieldName;
             fieldControl.FieldAlias    = productFieldInfo.Alias;
             fieldControl.FieldId       = productFieldInfo.AutoID;
             fieldControl.Settings      = XmlSerializerUtils.Deserialize <SinGooCMS.Control.FieldSetting>(productFieldInfo.Setting);
             fieldControl.DataLength    = productFieldInfo.DataLength;
             fieldControl.EnableNull    = productFieldInfo.EnableNull;
             if (!string.IsNullOrEmpty(productFieldInfo.Value))
             {
                 fieldControl.Value = productFieldInfo.Value;
             }
             else
             {
                 fieldControl.Value = (productFieldInfo.DefaultValue ?? string.Empty);
             }
         }
     }
 }
Example #7
0
        public async Task <CbCurrencyJsonResponseModel> GetDailyCurrencies()
        {
            var response = await _RestProvider.GetAsync("XML_daily.asp");

            if (response.IsSuccess)
            {
                var xmlModel  = XmlSerializerUtils.Deserialize <CbCurrencyXmlResponseModel>(response.Content);
                var jsonModel = xmlModel.ToJsonModel();
                return(jsonModel);
            }
            else
            {
                return(null);
            }
        }
Example #8
0
        private void Save()
        {
            if (_changed)
            {
                lock (_syncRoot)
                {
                    if (!Directory.Exists(_fileDir))
                    {
                        Directory.CreateDirectory(_fileDir);
                    }

                    XmlSerializerUtils.Serializer(_filePath, _innerSettings);
                }
            }
        }
Example #9
0
        public static List <OAuthConfig> LoadAll()
        {
            List <OAuthConfig> result;

            try
            {
                string xmlString = File.ReadAllText(HttpContext.Current.Server.MapPath("/Config/thirdlogin.config"));
                result = XmlSerializerUtils.Deserialize <List <OAuthConfig> >(xmlString);
            }
            catch
            {
                result = new List <OAuthConfig>();
            }
            return(result);
        }
Example #10
0
        private void SaveUniqueResults(List <ReverseCoverageResult> uniqueResults,
                                       string reportsFolder, string fileName)
        {
            var types = uniqueResults.Select(r => r.Model.GetType()).ToList();

            types.AddRange(uniqueResults.Select(r => r.Model.GetType()).ToList());

            types.Add(typeof(ModelValidationResult));
            types.Add(typeof(PropertyValidationResult));

            var xml = XmlSerializerUtils.SerializeToString(uniqueResults, types);

            xml = MakeHTMLLookGreat(xml);

            System.IO.File.WriteAllText(reportsFolder + "/" + fileName, xml);
        }
Example #11
0
        private List <string> RestoreMappings()
        {
            var fileName = "regresion-mapping.txt";

            var result = new List <string>();

            if (File.Exists(fileName))
            {
                var value = File.ReadAllText(fileName).Trim();

                if (!string.IsNullOrEmpty(value))
                {
                    result = XmlSerializerUtils.DeserializeFromString <List <string> >(value);
                }
            }

            return(result);
        }
Example #12
0
        public static NodeSetting LoadNodeSetting(string settings)
        {
            NodeSetting result;

            if (string.IsNullOrEmpty(settings))
            {
                result = new NodeSetting();
            }
            else
            {
                NodeSetting nodeSetting = XmlSerializerUtils.Deserialize <NodeSetting>(settings);
                if (nodeSetting == null)
                {
                    nodeSetting = new NodeSetting();
                }
                result = nodeSetting;
            }
            return(result);
        }
        public static void SaveConfig(ISetting setting)
        {
            if (setting == null)
            {
                return;
            }

            string filePath = GetFilePath(setting.GetType());

            lock (GetLock(setting.GetType()))
            {
                string dir = GetFileDir();
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                XmlSerializerUtils.Serializer(filePath, setting);
            }
        }
Example #14
0
        private void SaveMappings(List <string> mappings)
        {
            var value = XmlSerializerUtils.SerializeToString(mappings);

            File.WriteAllText("regresion-mapping.txt", value);
        }
Example #15
0
 public static void Save(List <OAuthConfig> lstConfig)
 {
     File.WriteAllText(HttpContext.Current.Server.MapPath("/Config/thirdlogin.config"), XmlSerializerUtils.SerializeList <OAuthConfig>(lstConfig));
 }
Example #16
0
        private void InitForModify()
        {
            UserFieldInfo dataById = SinGooCMS.BLL.UserField.GetDataById(base.OpID);

            if (dataById != null)
            {
                this.TextBox2.Text    = dataById.FieldName;
                this.TextBox2.Enabled = false;
                this.TextBox3.Text    = dataById.Alias;
                this.TextBox4.Text    = dataById.Tip;
                ListItem listItem = this.DropDownList5.Items.FindByValue(((FieldType)dataById.FieldType).ToString());
                if (listItem != null)
                {
                    listItem.Selected = true;
                }
                if (dataById.IsSystem)
                {
                    this.DropDownList5.Enabled = false;
                }
                switch (dataById.FieldType)
                {
                case 0:
                    this.ShowGroup = "group1";
                    break;

                case 1:
                    this.ShowGroup = "group2";
                    break;

                case 2:
                    this.ShowGroup = "group7";
                    break;

                case 4:
                case 5:
                case 6:
                    this.ShowGroup = "group3";
                    break;

                case 7:
                    this.ShowGroup = "group6";
                    break;

                case 8:
                case 10:
                    this.ShowGroup = "group4";
                    break;

                case 9:
                case 11:
                    this.ShowGroup = "group5";
                    break;
                }
                this.TextBox6.Text     = dataById.DefaultValue;
                this.CheckBox9.Checked = dataById.EnableNull;
                this.ExtTextBox5.Text  = dataById.DataLength.ToString();
                if (dataById.IsSystem)
                {
                    this.ExtTextBox5.Enabled = false;
                }
                SinGooCMS.Control.FieldSetting fieldSetting = XmlSerializerUtils.Deserialize <SinGooCMS.Control.FieldSetting>(dataById.Setting);
                if (fieldSetting != null)
                {
                    this.ExtTextBox1.Text = fieldSetting.ControlWidth.ToString();
                    this.ExtTextBox2.Text = fieldSetting.ControlHeight.ToString();
                    ListItem listItem2 = this.ExtRadioButtonList3.Items.FindByValue(fieldSetting.TextMode);
                    if (listItem2 != null)
                    {
                        listItem2.Selected = true;
                    }
                    this.ExtTextBox4.Text = fieldSetting.DataFormat;
                    ListItem listItem3 = this.ExtDropDownList6.Items.FindByValue(fieldSetting.DataFrom);
                    if (listItem3 != null)
                    {
                        listItem3.Selected = true;
                    }
                    string dataFrom = fieldSetting.DataFrom;
                    if (dataFrom != null)
                    {
                        if (!(dataFrom == "Text"))
                        {
                            if (!(dataFrom == "DataDictionary"))
                            {
                                if (!(dataFrom == "SQLQuery"))
                                {
                                    if (dataFrom == "AjaxData")
                                    {
                                        this.ExtTextBox11.Text = fieldSetting.DataSource;
                                        this.DataSource        = "AjaxData";
                                    }
                                }
                                else
                                {
                                    this.ExtTextBox9.Text = fieldSetting.DataSource;
                                    this.DataSource       = "SQLQuery";
                                }
                            }
                            else
                            {
                                this.ExtTextBox8.Text = fieldSetting.DataSource;
                                this.DataSource       = "DataDictionary";
                            }
                        }
                        else
                        {
                            this.ExtTextBox7.Text = fieldSetting.DataSource;
                            this.DataSource       = "Text";
                        }
                    }
                }
            }
        }
Example #17
0
        protected void btnok_Click(object sender, System.EventArgs e)
        {
            if (base.Action.Equals(ActionType.Add.ToString()) && !base.IsAuthorizedOp(ActionType.Add.ToString()))
            {
                base.ShowMsg("Không có thẩm quyền");
            }
            else if (base.Action.Equals(ActionType.Modify.ToString()) && !base.IsAuthorizedOp(ActionType.Modify.ToString()))
            {
                base.ShowMsg("Không có thẩm quyền");
            }
            else
            {
                UserFieldInfo userFieldInfo = new UserFieldInfo();
                if (base.IsEdit)
                {
                    userFieldInfo = SinGooCMS.BLL.UserField.GetDataById(base.OpID);
                }
                userFieldInfo.UserGroupID = this.modelParent.AutoID;
                userFieldInfo.FieldName   = WebUtils.GetString(this.TextBox2.Text);
                userFieldInfo.Alias       = WebUtils.GetString(this.TextBox3.Text);
                userFieldInfo.Tip         = WebUtils.GetString(this.TextBox4.Text);
                userFieldInfo.FieldType   = (int)((FieldType)System.Enum.Parse(typeof(FieldType), this.DropDownList5.SelectedValue));
                userFieldInfo.DataLength  = 50;
                if (string.IsNullOrEmpty(userFieldInfo.FieldName) || string.IsNullOrEmpty(userFieldInfo.Alias))
                {
                    base.ShowMsg("字段名称/Tên hiển thị không thể để trống");
                }
                else
                {
                    userFieldInfo.DefaultValue = WebUtils.GetString(this.TextBox6.Text);
                    SinGooCMS.Control.FieldSetting fieldSetting = new SinGooCMS.Control.FieldSetting();
                    fieldSetting.ControlWidth  = WebUtils.GetInt(this.ExtTextBox1.Text);
                    fieldSetting.ControlHeight = WebUtils.GetInt(this.ExtTextBox2.Text);
                    fieldSetting.TextMode      = this.ExtRadioButtonList3.SelectedValue;
                    fieldSetting.IsDataType    = userFieldInfo.FieldType.Equals(FieldType.DateTimeType);
                    fieldSetting.DataFormat    = WebUtils.GetString(this.ExtTextBox4.Text);
                    FieldType fieldType = (FieldType)userFieldInfo.FieldType;
                    if (fieldType != FieldType.MultipleHtmlType)
                    {
                        if (fieldType != FieldType.DateTimeType)
                        {
                            userFieldInfo.DataType   = "nvarchar";
                            userFieldInfo.DataLength = WebUtils.GetInt(this.ExtTextBox5.Text, 50);
                        }
                        else
                        {
                            userFieldInfo.DataType = "datetime";
                        }
                    }
                    else
                    {
                        userFieldInfo.DataType = "ntext";
                    }
                    fieldSetting.DataFrom = this.ExtDropDownList6.SelectedValue;
                    string dataFrom = fieldSetting.DataFrom;
                    if (dataFrom != null)
                    {
                        if (!(dataFrom == "Text"))
                        {
                            if (!(dataFrom == "DataDictionary"))
                            {
                                if (!(dataFrom == "SQLQuery"))
                                {
                                    if (dataFrom == "AjaxData")
                                    {
                                        fieldSetting.DataSource = WebUtils.GetString(this.ExtTextBox11.Text);
                                    }
                                }
                                else
                                {
                                    fieldSetting.DataSource = WebUtils.GetString(this.ExtTextBox9.Text);
                                }
                            }
                            else
                            {
                                fieldSetting.DataSource = WebUtils.GetString(this.ExtTextBox8.Text);
                            }
                        }
                        else
                        {
                            fieldSetting.DataSource = this.ExtTextBox7.Text;
                        }
                    }
                    userFieldInfo.Setting    = XmlSerializerUtils.Serialize <SinGooCMS.Control.FieldSetting>(fieldSetting);
                    userFieldInfo.IsUsing    = this.CheckBox7.Checked;
                    userFieldInfo.EnableNull = this.CheckBox9.Checked;
                    if (base.Action.Equals(ActionType.Add.ToString()))
                    {
                        userFieldInfo.AutoTimeStamp = System.DateTime.Now;
                        userFieldInfo.IsSystem      = false;
                        userFieldInfo.Sort          = SinGooCMS.BLL.UserField.MaxSort + 1;
                        FieldAddState fieldAddState  = SinGooCMS.BLL.UserField.Add(userFieldInfo);
                        FieldAddState fieldAddState2 = fieldAddState;
                        switch (fieldAddState2)
                        {
                        case FieldAddState.Error:
                            base.ShowMsg("Tạo trường thất bại");
                            break;

                        case FieldAddState.FieldNameIsUsing:
                            base.ShowMsg("Tên trường đã được sử dụng");
                            break;

                        case FieldAddState.FieldNameExists:
                            base.ShowMsg("Tên trường đã tồn tại");
                            break;

                        case FieldAddState.ModelNotExists:
                            base.ShowMsg("没有找到会员组");
                            break;

                        case FieldAddState.CreateColumnError:
                            base.ShowMsg("Tạo cột dữ liệu thất bại");
                            break;

                        default:
                            if (fieldAddState2 != FieldAddState.Success)
                            {
                                base.ShowMsg("Lỗi Unknown");
                            }
                            else
                            {
                                PageBase.log.AddEvent(base.LoginAccount.AccountName, "添加会员组字段[" + userFieldInfo.FieldName + "] thành công");
                                base.Response.Redirect(string.Concat(new object[]
                                {
                                    "UserField.aspx?CatalogID=",
                                    base.CurrentCatalogID,
                                    "&Module=",
                                    base.CurrentModuleCode,
                                    "&GroupID=",
                                    this.intModelID,
                                    "&action=View"
                                }));
                            }
                            break;
                        }
                    }
                    if (base.Action.Equals(ActionType.Modify.ToString()))
                    {
                        if (SinGooCMS.BLL.UserField.Update(userFieldInfo))
                        {
                            PageBase.log.AddEvent(base.LoginAccount.AccountName, "修改会员组字段[" + userFieldInfo.FieldName + "] thành công");
                            base.Response.Redirect(string.Concat(new object[]
                            {
                                "UserField.aspx?CatalogID=",
                                base.CurrentCatalogID,
                                "&Module=",
                                base.CurrentModuleCode,
                                "&GroupID=",
                                this.intModelID,
                                "&action=View"
                            }));
                        }
                        else
                        {
                            base.ShowMsg("修改会员组字段失败");
                        }
                    }
                }
            }
        }
Example #18
0
        private void InitForModify()
        {
            SettingInfo entityById = SettingProvider.GetEntityById(base.OpID);

            if (entityById != null)
            {
                this.TextBox1.Text = entityById.KeyName;
                this.TextBox3.Text = entityById.KeyDesc;
                ListItem listItem = this.DropDownList5.Items.FindByValue(entityById.ControlType);
                if (listItem != null)
                {
                    listItem.Selected = true;
                }
                switch ((FieldType)System.Enum.Parse(typeof(FieldType), entityById.ControlType))
                {
                case FieldType.SingleTextType:
                    this.ShowGroup = "group1";
                    break;

                case FieldType.MultipleTextType:
                    this.ShowGroup = "group2";
                    break;

                case FieldType.MultipleHtmlType:
                    this.ShowGroup = "group7";
                    break;

                case FieldType.RadioButtonType:
                case FieldType.CheckBoxType:
                case FieldType.DropDownListType:
                    this.ShowGroup = "group3";
                    break;

                case FieldType.DateTimeType:
                    this.ShowGroup = "group6";
                    break;

                case FieldType.PictureType:
                case FieldType.FileType:
                    this.ShowGroup = "group4";
                    break;

                case FieldType.MultiPictureType:
                case FieldType.MultiFileType:
                    this.ShowGroup = "group5";
                    break;
                }
                this.TextBox6.Text     = entityById.DefaultValue;
                this.CheckBox7.Checked = entityById.IsUsing;
                this.ExtTextBox5.Text  = entityById.DataLength.ToString();
                SinGooCMS.Control.FieldSetting fieldSetting = XmlSerializerUtils.Deserialize <SinGooCMS.Control.FieldSetting>(entityById.Setting);
                if (fieldSetting != null)
                {
                    this.ExtTextBox1.Text = fieldSetting.ControlWidth.ToString();
                    this.ExtTextBox2.Text = fieldSetting.ControlHeight.ToString();
                    ListItem listItem2 = this.ExtRadioButtonList3.Items.FindByValue(fieldSetting.TextMode);
                    if (listItem2 != null)
                    {
                        listItem2.Selected = true;
                    }
                    this.ExtTextBox4.Text = fieldSetting.DataFormat;
                    ListItem listItem3 = this.ExtDropDownList6.Items.FindByValue(fieldSetting.DataFrom);
                    if (listItem3 != null)
                    {
                        listItem3.Selected = true;
                    }
                    string dataFrom = fieldSetting.DataFrom;
                    if (dataFrom != null)
                    {
                        if (!(dataFrom == "Text"))
                        {
                            if (!(dataFrom == "DataDictionary"))
                            {
                                if (!(dataFrom == "SQLQuery"))
                                {
                                    if (dataFrom == "AjaxData")
                                    {
                                        this.ExtTextBox11.Text = fieldSetting.DataSource;
                                        this.DataSource        = "AjaxData";
                                    }
                                }
                                else
                                {
                                    this.ExtTextBox9.Text = fieldSetting.DataSource;
                                    this.DataSource       = "SQLQuery";
                                }
                            }
                            else
                            {
                                this.ExtTextBox8.Text = fieldSetting.DataSource;
                                this.DataSource       = "DataDictionary";
                            }
                        }
                        else
                        {
                            this.ExtTextBox7.Text = fieldSetting.DataSource;
                            this.DataSource       = "Text";
                        }
                    }
                }
            }
        }
Example #19
0
 public static DocSample FromXml(string xml)
 {
     return(XmlSerializerUtils.DeserializeFromString <DocSample>(xml));
 }
Example #20
0
        public static NodeAddStatus Add(NodeInfo node, out int newNodeID)
        {
            newNodeID = 0;
            NodeAddStatus result;

            if (Node.GetMainNodeCount() >= Ver.GetVer().NodeLimit&& node.IsShowOnMenu)
            {
                result = NodeAddStatus.ToMoreNode;
            }
            else
            {
                node.Creator    = Account.GetLoginAccount().AccountName;
                node.ChildCount = 0;
                int num = Node.ExistsNode(node.ParentID, node.NodeName, node.UrlRewriteName, "Add", 0);
                if (num > 0)
                {
                    result = (NodeAddStatus)num;
                }
                else
                {
                    if (node.ParentID > 0)
                    {
                        NodeInfo cacheNodeById = Node.GetCacheNodeById(node.ParentID);
                        if (cacheNodeById == null)
                        {
                            result = NodeAddStatus.ParentNodeNotExists;
                            return(result);
                        }
                        node.ParentPath = cacheNodeById.ParentPath + "," + cacheNodeById.AutoID.ToString();
                        node.RootID     = cacheNodeById.RootID;
                        node.Depth      = cacheNodeById.Depth + 1;
                        node.Sort       = BizBase.dbo.GetValue <int>(" SELECT max(Sort) FROM cms_Node WHERE ParentID=" + node.RootID) + 1;
                    }
                    else
                    {
                        node.ParentPath = "0";
                        node.Depth      = 1;
                        node.Sort       = BizBase.dbo.GetValue <int>(" SELECT max(Sort) FROM cms_Node WHERE ParentID=0") + 1;
                    }
                    node.Setting = XmlSerializerUtils.Serialize <NodeSetting>(node.NodeSetting);
                    newNodeID    = BizBase.dbo.InsertModel <NodeInfo>(node);
                    if (newNodeID > 0)
                    {
                        node.AutoID = newNodeID;
                        BizBase.dbo.ExecSQL(string.Concat(new object[]
                        {
                            " UPDATE cms_Node SET ChildList = '",
                            newNodeID,
                            "' WHERE AutoID=",
                            newNodeID
                        }));
                        if (node.ParentID > 0)
                        {
                            BizBase.dbo.ExecSQL(" UPDATE CMS_Node SET ChildCount = ChildCount + 1 WHERE AutoID =" + node.ParentID);
                            Node.UpdateNowParents(node, "Add");
                        }
                        else
                        {
                            BizBase.dbo.ExecSQL(string.Concat(new object[]
                            {
                                " UPDATE cms_Node SET RootID = ",
                                newNodeID,
                                " WHERE AutoID=",
                                newNodeID
                            }));
                        }
                        CacheUtils.Del("JsonLeeCMS_CacheForGetCMSNode");
                        result = NodeAddStatus.Success;
                    }
                    else
                    {
                        CacheUtils.Del("JsonLeeCMS_CacheForGetCMSNode");
                        result = NodeAddStatus.Error;
                    }
                }
            }
            return(result);
        }
Example #21
0
 public string ToXml()
 {
     return(XmlSerializerUtils.SerializeToString(this));
 }
Example #22
0
        protected void btnok_Click(object sender, System.EventArgs e)
        {
            if (base.Action.Equals(ActionType.Add.ToString()) && !base.IsAuthorizedOp(ActionType.Add.ToString()))
            {
                base.ShowMsg("Không có thẩm quyền");
            }
            else if (base.Action.Equals(ActionType.Modify.ToString()) && !base.IsAuthorizedOp(ActionType.Modify.ToString()))
            {
                base.ShowMsg("Không có thẩm quyền");
            }
            else
            {
                SettingInfo settingInfo = new SettingInfo();
                if (base.IsEdit)
                {
                    settingInfo = SettingProvider.GetEntityById(base.OpID);
                }
                settingInfo.KeyName = WebUtils.GetString(this.TextBox1.Text);
                settingInfo.CateID  = ((this.cate == null) ? 0 : this.cate.AutoID);
                settingInfo.KeyDesc = WebUtils.GetString(this.TextBox3.Text);
                if (settingInfo.CateID == 0)
                {
                    base.ShowMsg("Chọn phân loại Cấu hình");
                }
                else if (string.IsNullOrEmpty(settingInfo.KeyName))
                {
                    base.ShowMsg("Cấu hình tên chủ chốt không thể để trống");
                }
                else if (string.IsNullOrEmpty(settingInfo.KeyDesc))
                {
                    base.ShowMsg("Tên hiển thị không thể để trống");
                }
                else
                {
                    settingInfo.DataLength   = WebUtils.GetInt(this.ExtTextBox5.Text, 50);
                    settingInfo.ControlType  = this.DropDownList5.SelectedValue;
                    settingInfo.DefaultValue = WebUtils.GetString(this.TextBox6.Text);
                    SinGooCMS.Control.FieldSetting fieldSetting = new SinGooCMS.Control.FieldSetting();
                    fieldSetting.ControlWidth  = WebUtils.GetInt(this.ExtTextBox1.Text);
                    fieldSetting.ControlHeight = WebUtils.GetInt(this.ExtTextBox2.Text);
                    fieldSetting.TextMode      = this.ExtRadioButtonList3.SelectedValue;
                    fieldSetting.IsDataType    = settingInfo.ControlType.Equals(FieldType.DateTimeType);
                    fieldSetting.DataFormat    = WebUtils.GetString(this.ExtTextBox4.Text);
                    FieldType fieldType = (FieldType)System.Enum.Parse(typeof(FieldType), settingInfo.ControlType);
                    switch (fieldType)
                    {
                    case FieldType.MultipleTextType:
                    case FieldType.MultipleHtmlType:
                        settingInfo.DataType = "ntext";
                        break;

                    default:
                        if (fieldType != FieldType.DateTimeType)
                        {
                            settingInfo.DataType   = "nvarchar";
                            settingInfo.DataLength = WebUtils.GetInt(this.ExtTextBox5.Text, 50);
                        }
                        else
                        {
                            settingInfo.DataType = "datetime";
                        }
                        break;
                    }
                    fieldSetting.DataFrom = this.ExtDropDownList6.SelectedValue;
                    string dataFrom = fieldSetting.DataFrom;
                    if (dataFrom != null)
                    {
                        if (!(dataFrom == "Text"))
                        {
                            if (!(dataFrom == "DataDictionary"))
                            {
                                if (!(dataFrom == "SQLQuery"))
                                {
                                    if (dataFrom == "AjaxData")
                                    {
                                        fieldSetting.DataSource = WebUtils.GetString(this.ExtTextBox11.Text);
                                    }
                                }
                                else
                                {
                                    fieldSetting.DataSource = WebUtils.GetString(this.ExtTextBox9.Text);
                                }
                            }
                            else
                            {
                                fieldSetting.DataSource = WebUtils.GetString(this.ExtTextBox8.Text);
                            }
                        }
                        else
                        {
                            fieldSetting.DataSource = this.ExtTextBox7.Text;
                        }
                    }
                    settingInfo.Setting  = XmlSerializerUtils.Serialize <SinGooCMS.Control.FieldSetting>(fieldSetting);
                    settingInfo.IsUsing  = this.CheckBox7.Checked;
                    settingInfo.IsSystem = false;
                    settingInfo.Sort     = 9999;
                    if (base.Action.Equals(ActionType.Add.ToString()))
                    {
                        if (SettingProvider.ExistsByName(settingInfo.KeyName))
                        {
                            base.ShowMsg("Cấu hình tùy chỉnh cùng tên đã tồn tại");
                            return;
                        }
                        settingInfo.AutoTimeStamp = System.DateTime.Now;
                        if (SettingProvider.Add(settingInfo) > 0)
                        {
                            CacheUtils.Del("JsonLeeCMS_CacheForGetSetting");
                            CacheUtils.Del("JsonLeeCMS_CacheForSETTINGDIRECTORY");
                            PageBase.log.AddEvent(base.LoginAccount.AccountName, "Thêm cấu hình tùy chỉnh [" + settingInfo.KeyDesc + "] thành công");
                            base.Response.Redirect(string.Concat(new object[]
                            {
                                "CustomSetting.aspx?CatalogID=",
                                base.CurrentCatalogID,
                                "&Module=",
                                base.CurrentModuleCode,
                                "&cateid=",
                                this.cate.AutoID,
                                "&action=View"
                            }));
                        }
                        else
                        {
                            base.ShowMsg("Thêm cấu hình tùy chỉnh thất bại");
                        }
                    }
                    if (base.Action.Equals(ActionType.Modify.ToString()))
                    {
                        if (SettingProvider.Update(settingInfo))
                        {
                            CacheUtils.Del("JsonLeeCMS_CacheForGetSetting");
                            CacheUtils.Del("JsonLeeCMS_CacheForSETTINGDIRECTORY");
                            PageBase.log.AddEvent(base.LoginAccount.AccountName, "Sửa đổi các cấu hình tùy chỉnh [" + settingInfo.KeyDesc + "] thành công");
                            base.Response.Redirect(string.Concat(new object[]
                            {
                                "CustomSetting.aspx?CatalogID=",
                                base.CurrentCatalogID,
                                "&Module=",
                                base.CurrentModuleCode,
                                "&cateid=",
                                this.cate.AutoID,
                                "&action=View"
                            }));
                        }
                        else
                        {
                            base.ShowMsg("Sửa đổi các cấu hình tùy chỉnh thất bại");
                        }
                    }
                }
            }
        }