Esempio n. 1
0
        public static IList <ImageCut> GetImageCutsByUploadName(string uploadName)
        {
            FileUploadConfig config = GetFileUploadConfig(uploadName);

            AtawDebug.AssertArgumentNullOrEmpty(config.Name,
                                                string.Format(ObjectUtil.SysCulture, "名称为{0}的上传配置节点不存在截图配置", uploadName),
                                                AtawAppContext.Current);

            return(GetImageCutsByCutConfigName(config.ImageCutGroupName));
        }
Esempio n. 2
0
        /// <summary>
        /// 将数据保存到相应的文件中
        /// </summary>
        /// <param name="fileName">文件名</param>
        /// <param name="content">需要保存的数据</param>
        /// <param name="encoding">文件的编码形式</param>
        public static void SaveFile(string fileName, string content, Encoding encoding)
        {
            AtawDebug.AssertArgumentNullOrEmpty(fileName, "fileName", null);
            AtawDebug.AssertArgumentNull(content, "content", null);
            AtawDebug.AssertArgumentNull(encoding, "encoding", null);

            FileStream file = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.Read);

            using (TextWriter writer = new StreamWriter(file, encoding))
            {
                writer.Write(content);
            }
        }
Esempio n. 3
0
        public static void JoinStringItem(StringBuilder builder, int index, string value, string joinStr)
        {
            AtawDebug.AssertArgumentNull(builder, "builder", null);
            AtawDebug.AssertArgumentNullOrEmpty(value, "value", null);
            AtawDebug.AssertArgumentNull(joinStr, "joinStr", null);
            AtawDebug.AssertArgument(index >= 0, "index", string.Format(ObjectUtil.SysCulture,
                                                                        "index的值不能为负数,现在是{0}", index), null);

            if (index > 0)
            {
                builder.Append(joinStr);
            }
            builder.Append(value);
        }
Esempio n. 4
0
        public T this[string name]
        {
            get
            {
                AtawDebug.AssertArgumentNullOrEmpty(name, "name", this);

                ListNode <T> node;
                if (fDictionary.TryGetValue(name, out node))
                {
                    return(node.Value);
                }
                return(default(T));
            }
        }
 public static void MergeColumns(FormConfig form, DataFormConfig dataForm, ModuleConfig moduleConfig)
 {
     if (form.FormColumnRight != null)
     {
         ColumnRightConfig columnRight     = null;
         string            columnRightname = form.FormColumnRight.Name;
         if (form.FormColumnRight.RegName.IsEmpty())
         {
             AtawDebug.AssertArgumentNullOrEmpty(columnRightname, "FormColumnRight中若没指定RegName,Name属性不能为空", moduleConfig);
             columnRight = moduleConfig.Right.ColumnRights.FirstOrDefault(a => a.Name == columnRightname);
             AtawDebug.AssertArgumentNull(columnRight, string.Format("ModuleXml中必须配置名为'{0}'的ColumnRight", columnRightname), moduleConfig);
         }
         else
         {
             IColumnRight columnRightPlug = form.FormColumnRight.RegName.CodePlugIn <IColumnRight>();
             columnRightname = columnRightPlug.GetColumnRightName();
             columnRight     = moduleConfig.Right.ColumnRights.FirstOrDefault(a => a.Name == columnRightname);
             AtawDebug.AssertArgumentNull(columnRight, string.Format("ModuleXml中必须配置名为'{0}'的ColumnRight", columnRightname), moduleConfig);
         }
         //if (columnRight.Delete != null)
         //{
         //    columnRight.Delete.ForEach(dCol =>
         //    {
         //        var col = dataForm.Columns.FirstOrDefault(baseCol => baseCol.Name.Equals(dCol.Name, StringComparison.OrdinalIgnoreCase));
         //        if (col != null)
         //            dataForm.Columns.Remove(col);
         //    });
         //}
         if (columnRight.Override != null)
         {
             columnRight.Override.ForEach(oCol =>
             {
                 var col = dataForm.Columns.FirstOrDefault(baseCol => baseCol.Name.Equals(oCol.BaseColumnName, StringComparison.OrdinalIgnoreCase));
                 if (col != null)
                 {
                     AssignColumn(oCol, col);
                 }
             });
         }
         if (columnRight.Add != null)
         {
             dataForm.Columns.AddRange(columnRight.Add);
         }
     }
 }
Esempio n. 6
0
        /// <summary>
        /// 格式化SQL语句中的WHERE条件
        /// </summary>
        /// <param name="sql">SQL字符串</param>
        /// <param name="whereClause">where子句</param>
        /// <returns>被替换where子句的sql</returns>
        internal static string ReplaceWhereClause(string sql, string whereClause)
        {
            AtawDebug.AssertArgumentNullOrEmpty(sql, "sql", null);
            AtawDebug.AssertArgumentNull(whereClause, "whereClause", null);

            int    index = sql.IndexOf("WHERE", StringComparison.OrdinalIgnoreCase);
            string result;

            if (index > 0)
            {
                result = sql.Substring(0, index - 1);
            }
            else
            {
                result = sql;
            }
            result += " " + whereClause;
            return(result);
        }
        private static ColumnRightConfig GetColumnRight(FormConfig form, DataFormConfig dataForm, ModuleConfig moduleConfig)
        {
            ColumnRightConfig columnRight     = null;
            string            columnRightname = form.FormColumnRight.Name;

            if (form.FormColumnRight.RegName.IsEmpty())
            {
                AtawDebug.AssertArgumentNullOrEmpty(columnRightname, "FormColumnRight中若没指定RegName,Name属性不能为空", moduleConfig);
                columnRight = moduleConfig.Right.ColumnRights.FirstOrDefault(a => a.Name == columnRightname);
                AtawDebug.AssertArgumentNull(columnRight, string.Format("ModuleXml中必须配置名为'{0}'的ColumnRight", columnRightname), moduleConfig);
            }
            else
            {
                IColumnRight columnRightPlug = form.FormColumnRight.RegName.CodePlugIn <IColumnRight>();
                columnRightname = columnRightPlug.GetColumnRightName();
                columnRight     = moduleConfig.Right.ColumnRights.FirstOrDefault(a => a.Name == columnRightname);
                AtawDebug.AssertArgumentNull(columnRight, string.Format("ModuleXml中必须配置名为'{0}'的ColumnRight", columnRightname), moduleConfig);
            }
            return(columnRight);
        }
        /// <summary>
        /// 构造函数,初始化自定义特性基类
        /// </summary>
        /// <param name="regName">注册名,整个应用系统中不能重复注册</param>
        protected BasePlugInAttribute(string regName)
        {
            AtawDebug.AssertArgumentNullOrEmpty(regName, "regName", this);

            RegName = regName;
        }
Esempio n. 9
0
 public bool ContainsKey(string key)
 {
     AtawDebug.AssertArgumentNullOrEmpty(key, "key", this);
     return(fDictionary.ContainsKey(key));
 }
Esempio n. 10
0
 public virtual void SaveFileByName()
 {
     AtawDebug.AssertArgumentNullOrEmpty(FileName, "FileName", this);
     SaveFileByName(FileName);
 }
        protected virtual AtawColumnConfigView CreateColumn(AtawFormConfigView formView, ColumnConfig column)
        {
            AtawColumnConfigView colView = new AtawColumnConfigView();

            colView.ControlType = column.ControlType;
            colView.DisplayName = column.DisplayName;
            colView.Prompt      = column.Prompt;
            colView.ValPrompt   = column.ValPrompt;

            //if ((PageStyle == PageStyle.Update || PageStyle == PageStyle.Insert) && colView.ValPrompt != null && column.ShowType > 0)
            //{

            //    column.ShowType = column.ShowType >= 3?0:2;

            //}
            if (column.Changer != null)
            {
                colView.Changer               = new ChangerViewConfig();
                colView.Changer.Expression    = column.Changer.Expression;
                colView.Changer.DependColumns = column.Changer.DependColumns;
                colView.Changer.NotifyColumns = column.Changer.NotifyColumns;
            }

            if (column.ShowType == 0 ||
                column.ControlType == ControlType.AllImageShow ||
                column.ControlType == ControlType.Editor ||
                column.ControlType == ControlType.EditorDetail ||
                column.ControlType == ControlType.ImageDetail ||
                column.ControlType == ControlType.PCAS ||
                column.ControlType == ControlType.MultiSelector ||
                column.ControlType == ControlType.MultiImageUpload ||
                column.ControlType == ControlType.SingleImageUpload ||
                column.ControlType == ControlType.SingleFileUpload ||
                column.ControlType == ControlType.MultiFileUpload ||
                column.ControlType == ControlType.FormMultiSelector ||
                column.ControlType == ControlType.TextArea)
            {
                colView.ShowType = "ColShowType".AppKv <int>(4);
            }
            else
            {
                colView.ShowType = column.ShowType;
            }
            if (column.ControlType == ControlType.Hidden)
            {
                colView.ShowType = 0;
            }
            colView.Sortable       = column.Sortable;
            colView.IsDetailLink   = column.IsDetailLink;
            colView.Name           = column.Name;
            colView.Kind           = column.Kind;
            colView.NormalStyle    = column.NormalStyle;
            colView.TdStyle        = column.TdStyle;
            colView.IsHiddenCol    = column.IsHiddenCol;
            colView.Width          = column.Width;
            colView.LinkFormat     = column.LinkFormat;
            colView.ChangeEventFun = column.ChangeEventFun;
            colView.Report         = column.Report;
            colView.TreeConfig     = column.TreeConfig;
            colView.ShortCutName   = column.ShortCutName;
            colView.Amount         = column.Amount;
            if (column.ControlType == ControlType.Custom)
            {
                AtawDebug.AssertArgumentNull(column.CustomControl, "Custom控件类型需要配置CustomControl", column);
                AtawDebug.AssertArgumentNullOrEmpty(column.CustomControl.ControlType, "CustomControl中必须指定自定义控件类型", column);
            }

            colView.CustomControl = column.CustomControl;
            if (column.ControlType == ControlType.Editor)
            {
                colView.Editor = column.Editor;
            }

            if (!column.SourceName.IsEmpty())
            {
                colView.QingColumnName = column.Name;
            }

            string controlRegname = column.ControlType.ToString();
            // to.Options
            var optionCreator = controlRegname.CodePlugIn <AtawOptionCreator>();

            //初始化
            optionCreator.Initialize(BasePageView, formView, column, PageStyle);
            //方法调用
            colView.Options = optionCreator.Create();
            return(colView);
        }
Esempio n. 12
0
        //[XmlArrayItem("ColumnRight")]
        //public List<ColumnRightConfig> ColumnRights { get; set; }

        //[XmlArrayItem("RightUnit")]
        //public List<RightUnitConfig> RightUnits { get; set; }

        //[XmlArrayItem("PageStyleRight")]
        //public List<PageStyleRightConfig> PageStyleRights { get; set; }


        //public bool HasPager { get; set; }

        //public int PageSize { get; set; }

        void IReadXmlCallback.OnReadXml()
        {
            if (Forms != null && Forms.Count > 0)
            {
                Forms.ForEach(a =>
                {
                    AtawDebug.AssertArgumentNullOrEmpty(a.Name, " 表单名称不能为空  ", this);
                    if (a is FormConfig)
                    {
                        var b = (FormConfig)a;
                        if ((b.DataPlug.IsEmpty()))
                        {
                            b.DataPlug = "EmptyDataTableSource";
                        }
                        //if (b.VerticalTab.ToString().IsEmpty())
                        //{
                        //    b.VerticalTab = false;
                        //}
                        if (b.Group.InternalShowPage.IsEmpty())
                        {
                            b.Group.ShowPage = PageStyle.All;
                        }
                        else
                        {
                            var arr = b.Group.InternalShowPage.Split('|');
                            arr.ToList().ForEach(str =>
                            {
                                b.Group.ShowPage = b.Group.ShowPage | str.ToEnum <PageStyle>();
                            });
                        }
                    }
                    if (a.Title != null && System.Text.Encoding.Default.GetBytes(a.Title.ToCharArray()).Length > 50)
                    {
                        throw new AtawException("Title长度设置不要超过25个中文或者50个英文", this);
                    }
                });
            }
            Forms = Forms.OrderBy(a => a.Order).ToList();


            Scripts.ForEach(a =>
            {
                if (a.InternalStyle.IsEmpty())
                {
                    a.Style = PageStyle.All;
                }
                else
                {
                    var arr = a.InternalStyle.Split('|');

                    arr.ToList().ForEach(str =>
                    {
                        a.Style = a.Style | str.ToEnum <PageStyle>();
                    });
                }
            });
            if (Right != null)
            {
                (Right as IReadXmlCallback).OnReadXml();
            }
        }