Example #1
0
 public string MatchValue(EcmItem item)
 {
     if(item == null) return null;
     string s = item[this.ColumnName];
     if(s == null) s = "";
     Match m = this.Regex.Match(s);
     if(m.Groups.Count > 1){
         return m.Groups[1].Value;
     }
     return null;
 }
Example #2
0
        private XmlNode GetAnchor(EcmItem item)
        {
            XmlNode result = myXhtml.CreateDocumentFragment();
            string title = item.Id + " : " + item.Title;

            if(myProject.Setting.PreviewRootUrl != null && item.File != null && item.File.Exists){
                string previewUrl = myProject.Setting.PreviewRootUrl.TrimEnd('/') + item.Path;
                XmlElement a = myXhtml.Create("a");
                a.SetAttribute("href", previewUrl);
                a.InnerText = title;
                result.AppendChild(a);
            } else {
                result.AppendChild(myXhtml.Text(title));
            }
            return result;
        }
Example #3
0
        private XmlNode GetChildItemUl(EcmItem item)
        {
            EcmItem[] children = item.ChildItems;
            if(children.Length <= 0) return myXhtml.CreateDocumentFragment();
            if(depthCount++ > Setting.DepthMax) {
                throw new Exception("�������̏���𒴂��܂����B�������[�v�̉”\��������܂��B" + item.ToString());
            }

            XmlElement result = myXhtml.Create("ul");
            foreach(EcmItem i in children){
                XmlElement li = myXhtml.Create("li");
                li.AppendChild(GetAnchor(i));
                li.AppendChild(GetChildItemUl(i));
                result.AppendChild(li);
            }
            return result;
        }
Example #4
0
        // ========
        // ECMItem �̃��X�g���� HTML �� table ��쐬���܂��B
        private XmlNode GetTable(EcmItem[] items, HttpRequest rq)
        {
            XmlElement form = myXhtml.Create("form");
            form.SetAttribute("action", "");
            form.SetAttribute("method", "post");
            XmlElement table = myXhtml.Create("table");

            // thead
            XmlElement thead = myXhtml.Create("thead");
            table.AppendChild(thead);
            XmlElement theadtr = myXhtml.Create("tr");
            thead.AppendChild(theadtr);
            foreach(DataColumn c in myProject.Columns){
                if(IsHiddenColumn(c.ColumnName)) continue;
                if(c == myProject.PathCol) continue;
                XmlElement th = myXhtml.Create("th");
                th.InnerText = c.ToString();
                theadtr.AppendChild(th);
            }

            // �F�������K�\��
            Regex idReg = null;
            string colorSeparateTargetColumn = null;
            if(!string.IsNullOrEmpty(myProject.Setting.ColorSeparateRule)){
                string[] colorSeparateRules = myProject.Setting.ColorSeparateRule.Split('=');
                string colorSeparateRegexStr = null;
                if(colorSeparateRules.Length == 1){
                    colorSeparateTargetColumn = myProject.IdCol.ColumnName;
                    colorSeparateRegexStr = colorSeparateRules[0];
                } else {
                    colorSeparateTargetColumn = colorSeparateRules[0];
                    colorSeparateRegexStr = colorSeparateRules[1];
                }
                try{
                    idReg = new Regex(colorSeparateRegexStr);
                } catch (ArgumentException e) {
                    myProject.Log.AddAlert("�F�������[���̐��K�\���ɃG���[������悤�ł��B���K�\���R���p�C���̃��b�Z�[�W : {1}", e.Message);
Example #5
0
        // �^����ꂽ EcmItem �ɑΉ�����t�@�C���� Parse ���Ēu�����܂��B
        public override ProcessResult Process(EcmItem targetItem)
        {
            ProcessResult result = new ProcessResult();

            // �v���W�F�N�g������O�o��
            Log.AddInfo("Project: {0}, FileTime:{1}, DataTime: {2}", Project.Id, Project.FileTime, Project.DataTime);

            // ���S�m�F
            string[] errorId = Project.GetDuplicateId();
            if(errorId.Length > 0){
                Log.AddError("ID: {0} ���d�����Ă��܂��B", string.Join(", ", errorId));
                return result;
            }
            Log.AddInfo("ID�̐�������m�F");

            string[] errorPath = Project.GetDuplicatePath();
            if(errorPath.Length > 0){
                Log.AddError("������ ID �� {0} ��Q�Ƃ��Ă��܂��B", string.Join(", ", errorPath));
                return result;
            }
            Log.AddInfo("Path�̐�������m�F");

            Log.AddInfo("ID : {0} �̍��ڂ𔭌�", targetItem.Id);

            if(string.IsNullOrEmpty(targetItem.Path)){
                Log.AddError("ID : {0} �ɂ� Path ���ݒ肳��Ă��Ȃ����߁A�p�[�X�ł��܂���B", targetItem.Id);
                return result;
            }

            // �t�@�C�������邩?
            // �O���[�o���e���v���[�g���w�肳��Ă���ꍇ�̓t�@�C���������Ă�������邱�Ƃɒ��ӁB
            Log.AddInfo("{0} �̃t�@�C�� : {1}", targetItem.Id, targetItem.FilePath);
            targetItem.File.Refresh();
            if(targetItem.File.Exists){
                // �t�@�C��������
                // �������݂ł��邩�ǂ��� (���b�N����Ă��Ȃ���) �m�F����
                try{
                    using(FileStream fs = targetItem.File.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None)){
                        fs.Close();
                    }
                    Log.AddInfo("�t�@�C�� {0} �͑��݂��܂����A�������݉”\�Ȃ悤�ł��B", targetItem.FilePath);
                } catch(IOException e){
                    result.AddError("�t�@�C�� {0} �͏������݂ł��Ȃ��悤�ł� : {1}", targetItem.FilePath, e.Message);
                    Log.AddError("�t�@�C�� {0} �͏������݂ł��Ȃ��悤�ł� : {1}", targetItem.FilePath, e.Message);
                    return result;
                } catch(UnauthorizedAccessException e){
                    result.AddError("�t�@�C�� {0} �͏������݂ł��Ȃ��悤�ł� : {1}", targetItem.FilePath, e.Message);
                    Log.AddError("�t�@�C�� {0} �͏������݂ł��Ȃ��悤�ł� : {1}", targetItem.FilePath, e.Message);
                    return result;
                }
                result.Result = Parse(targetItem, targetItem.File);
            } else {
                // �t�@�C�����Ȃ�
                if(targetItem.Template != null){
                    Log.AddInfo("�t�@�C�� {0} �͂���܂��񂪁A�O���[�o���e���v���[�g���w�肳��Ă��܂�(�e���v���[�g�� : {1})�B", targetItem.FilePath, targetItem.Template);
                    result.Result = Parse(targetItem, null);
                } else {
                    result.AddError("ID : {0} �̃t�@�C�� {1} ������܂��� (�O���[�o���e���v���[�g��w�肳��Ă��܂���)�B", targetItem.Id, targetItem.FilePath);
                    Log.AddError("ID : {0} �̃t�@�C�� {1} ������܂��� (�O���[�o���e���v���[�g��w�肳��Ă��܂���)�B", targetItem.Id, targetItem.FilePath);
                    return result;
                }
            }

            // �p�[�T�[�� null ��Ԃ�����I��
            if(result.Result == null){
                result.AddError("{0} �̃p�[�X�Ɏ��s���܂����B�p�[�X�I�����܂��B", targetItem.Id);
                Log.AddError("{0} �̃p�[�X�Ɏ��s���܂����B�t�@�C���ɏ������܂��ɏI�����܂��B", targetItem.Id);
                return result;
            }

            // �p�[�X���ʂƔ�r���Ă݂�
            if(result.Result == ReadData){
                // ���ʂ������Ȃ̂ʼn�����Ȃ�
                Log.AddInfo("�p�[�X�������܂������A���ʂ̓p�[�X�O�ƕω�����܂���ł����B");
                result.Message = "�p�[�X�������܂������A���ʂ̓p�[�X�O�ƕω�����܂���ł����B";
            } else {
                // ���ʂ��Ⴄ�̂ŏ�������
                Log.AddInfo("�p�[�X���ʂ̓p�[�X�O�ƈقȂ�܂��B�t�@�C���ւ̏������݂���݂܂��B");
                try{
                    if(!targetItem.File.Directory.Exists){
                        targetItem.File.Directory.Create();
                        Log.AddWarning("�f�B���N�g�� {0} ���݂‚���܂���ł����B�V�K�Ƀf�B���N�g����쐬���܂����B", targetItem.File.Directory.FullName);
                    }

                    using(FileStream fs = targetItem.File.Open(FileMode.Create, FileAccess.Write, FileShare.None)){
                        using(StreamWriter sw = new StreamWriter(fs, Project.Setting.HtmlEncodingObj)){
                            sw.Write(result.Result);
                            sw.Close();
                        }
                        fs.Close();
                    }
                    targetItem.File.Refresh();
                    string s = string.Format("�t�@�C�� {0} �ɏ������݂܂����B(�T�C�Y: {1})", targetItem.FilePath, targetItem.File.Length);
                    Log.AddInfo(s);
                    result.Message = s;
                } catch(IOException e){
                    result.AddError("�t�@�C�� {0} �ɏ������߂܂��� : {1}", targetItem.FilePath, e.Message);
                    Log.AddError("�t�@�C�� {0} �ɏ������߂܂��� : {1}", targetItem.FilePath, e.Message);
                    return result;
                } catch(UnauthorizedAccessException e){
                    result.AddError("�t�@�C�� {0} �ɏ������ތ���������܂��� : {1}", targetItem.FilePath, e.Message);
                    Log.AddError("�t�@�C�� {0} �ɏ������ތ���������܂��� : {1}", targetItem.FilePath, e.Message);
                    return result;
                }
            }
            return result;
        }
Example #6
0
        // EcmItem �ɑ΂��� Eval ��������s���܂��B
        private Object EvalItem(EcmItem ei, string memberStr)
        {
            if(memberStr == "") return ei;

            string[] members = memberStr.Split('(', ')');
            string memberName = members[0];
            string memberParam = null;

            // memberParam �� null���v���p�e�B�A""�������Ȃ����\�b�h�A�������遨�����‚����\�b�h
            if(members.Length > 1){
                // ���\�b�h
                Log.AddInfo("{0} ���\�b�h {1} ��F�m", Project.CurrentItem, memberStr);
                MethodInfo m;
                memberParam = members[1];
                if(memberParam == ""){
                    // �����i�V���\�b�h
                    Log.AddInfo("{0} ���\�b�h {1} �Ɉ����͎w�肳��Ă��܂���", Project.CurrentItem, memberStr);
                    m = typeof(EcmItem).GetMethod(memberName, Type.EmptyTypes);
                    if(m != null) return m.Invoke(ei, null);
                } else {
                    // �����‚����\�b�h
                    Log.AddInfo("{0} ���\�b�h {1} �̈����� {2} �ł�", Project.CurrentItem, memberStr, memberParam);
                    m = typeof(EcmItem).GetMethod(memberName, new Type[]{typeof(string)});
                    if(m != null) return m.Invoke(ei, new Object[]{memberParam});
                }
                // �݂‚���Ȃ�
                Log.AddWarning("���\�b�h�����‚���܂���ł��� : {0}.{1}", ei, memberStr);
                return null;
            }

            // �v���p�e�B
            Log.AddInfo("{0} �v���p�e�B {1} ��F�m", Project.CurrentItem, memberStr);
            PropertyInfo p;

            // �C���f�N�T�ɂ�����B
            if(ei[memberName] != null){
                Log.AddInfo("{0} �̃f�[�^ {1} ��擾���܂��� (�T�C�Y : {2})", ei.FqId, memberStr, ei[memberName].Length);
                return ei[memberName];
            }

            // EcmItem �̃f�t�H���g�v���p�e�B�ɂ�����
            p = typeof(EcmItem).GetProperty(memberName);
            if(p != null){
                Log.AddInfo("{0} �̃f�t�H���g�v���p�e�B {1} ��擾���܂��B", ei.FqId, memberStr);
                return p.GetValue(ei, null);
            }

            // Export�ɂ����� (Parse ���Ȃ��ŕԂ�)
            string expTarget = ei.GetExport(this, memberStr);
            if(expTarget != null){
                Log.AddInfo("{0} �� Export {1} ��擾���܂��� (�T�C�Y : {2})", ei.FqId, memberStr, expTarget.Length);
                return expTarget;
            }

            // �݂‚���Ȃ�
            Log.AddWarning("�v���p�e�B�����‚���܂���ł��� : {0}.{1}", ei, memberStr);
            return null;
        }

        // EcmString �Ƃ��̔h���N���X�ɑ΂��� Eval ��������s���܂��B
        private Object EvalString(EcmString o, string memberStr)
        {
            if(memberStr == "") return o;

            Type t = o.GetType();

            string[] members = memberStr.Split('(', ')');
            string memberName = members[0];
            string memberParam = null;

            // memberParam �� null���v���p�e�B�A""�������Ȃ����\�b�h�A�������遨�����‚����\�b�h
            if(members.Length > 1){
                // ���\�b�h
                Log.AddInfo("{0} ���\�b�h {1} ��F�m", Project.CurrentItem, memberStr);
                MethodInfo m;
                memberParam = members[1];
                if(memberParam == ""){
                    // �����i�V���\�b�h
                    Log.AddInfo("{0} ���\�b�h {1} �Ɉ����͎w�肳��Ă��܂���", Project.CurrentItem, memberStr);
                    m = t.GetMethod(memberName, Type.EmptyTypes);
                    if(m != null) return m.Invoke(o, null);
                } else {
                    // �����‚����\�b�h
                    Log.AddInfo("{0} ���\�b�h {1} �̈����� {2} �ł�", Project.CurrentItem, memberStr, memberParam);
                    m = t.GetMethod(memberName, new Type[]{typeof(string)});
                    if(m != null) return m.Invoke(o, new Object[]{memberParam});
                }
                // �݂‚���Ȃ�
                Log.AddWarning("���\�b�h�����‚���܂���ł��� : {0}.{1}", o, memberStr);
            } else {
                // �v���p�e�B
                Log.AddInfo("{0} �v���p�e�B {1} ��F�m", Project.CurrentItem, memberStr);
                PropertyInfo p;

                p = t.GetProperty(memberName);
                if(p != null) return p.GetValue(o, null);

                // �݂‚���Ȃ�
                Log.AddWarning("�v���p�e�B�����‚���܂���ł��� : {0}.{1}", o, memberStr);
            }
            return o;
        }
Example #7
0
        // ========
        // ECMItem �̃��X�g���� HTML �� table ��쐬���܂��B
        private XmlNode GetTable(EcmItem[] items, HttpRequest rq)
        {
            string pathCookie = GetCookie(rq, PathNameCookieLabelPrefix);
            string uriCookie = GetCookie(rq, LocalUriCookieLabelPrefix);

            XmlElement form = myXhtml.Create("form");
            form.SetAttribute("action", "");
            form.SetAttribute("method", "post");
            XmlElement table = myXhtml.Create("table");

            // thead
            XmlElement thead = myXhtml.Create("thead");
            table.AppendChild(thead);
            XmlElement theadtr = myXhtml.Create("tr");
            thead.AppendChild(theadtr);
            foreach(DataColumn c in myProject.Columns){
                if(IsHiddenColumn(c.ColumnName)) continue;
                XmlElement th = myXhtml.Create("th");
                XmlElement a = myXhtml.Create("a");
                a.InnerText = c.ToString();
                string hrefValue = string.Format("?{0}={1}", SortInputLabel, HttpUtility.UrlEncode(c.ColumnName));
                if(c.ColumnName == mySortColumn){
                    XmlElement sortSpan = myXhtml.Create("span", "sort");
                    if(myReverse){
                        sortSpan.InnerText +="��";
                    } else {
                        sortSpan.InnerText +="��";
                        hrefValue += string.Format("&{0}=1", SortReverseInputLabel);
                    }
                    a.AppendChild(sortSpan);
                }
                if(!string.IsNullOrEmpty(myWhereExpression)) hrefValue += '&' + WhereInputLabel + '=' + HttpUtility.UrlEncode(myWhereExpression);
                a.SetAttribute("href", hrefValue);
                th.AppendChild(a);
                if(c == myProject.IdCol && !string.IsNullOrEmpty(uriCookie)){
                    th.SetAttribute("colspan", "2");
                }
                theadtr.AppendChild(th);
            }

            // �����
            if(!string.IsNullOrEmpty(myProject.Setting.ImageDir)){
                XmlElement previewTh = myXhtml.Create("th");
                previewTh.InnerText = EccmPreviewName;
                theadtr.AppendChild(previewTh);
            }

            XmlElement parseTh = myXhtml.Create("th");
            parseTh.InnerText = EccmParseName;
            theadtr.AppendChild(parseTh);

            XmlElement sizeTh = myXhtml.Create("th");
            sizeTh.InnerText = EccmSizeName;
            theadtr.AppendChild(sizeTh);

            XmlElement timeTh = myXhtml.Create("th");
            timeTh.InnerText = EccmTimeName;
            theadtr.AppendChild(timeTh);

            // �F�������K�\��
            ColorPattern sepPattern = null;
            ColorPattern colorPattern1 = null;
            ColorPattern colorPattern2 = null;
            ColorPattern colorPattern3 = null;
            try{
                sepPattern = ColorPattern.Parse(myProject.Setting.ColorSeparateRule, myProject.IdCol.ColumnName);
                colorPattern1 = ColorPattern.Parse(myProject.Setting.ColorRule1, myProject.IdCol.ColumnName);
                colorPattern2 = ColorPattern.Parse(myProject.Setting.ColorRule2, myProject.IdCol.ColumnName);
                colorPattern3 = ColorPattern.Parse(myProject.Setting.ColorRule3, myProject.IdCol.ColumnName);
            } catch (ArgumentException e) {
                myProject.Log.AddAlert("�F�������[���̐��K�\���ɃG���[������悤�ł��B���K�\���R���p�C���̃��b�Z�[�W : {1}", e.Message);
Example #8
0
 // �R���X�g���N�^
 public ExportManager(Parser p, EcmItem item)
 {
     myParser = p;
     myItem = item;
 }
Example #9
0
 public bool IsMatch(EcmItem item)
 {
     string s = item[this.ColumnName];
     if(s == null) s = "";
     return this.Regex.IsMatch(s);
 }
Example #10
0
        public bool IsAncestorOf(EcmItem target)
        {
            if(target == null) return false;
            if(target.Parent == null) return false;

            // �z�ŽQ�ƃ`�F�b�N�p
            List<EcmItem> al = new List<EcmItem>();

            EcmItem item = target.ParentItem;
            for(;;){
                if(item == null) return false;
                if(item == this) return true;
                // �z�ŽQ�ƃ`�F�b�N
                foreach(EcmItem i in al){
                    if(i.FqId == item.FqId){
                        return false;
                    }
                }
                al.Add(item);
                item = item.ParentItem;
            }
        }
Example #11
0
 // ��=�l �ł���悤�� EcmItem �̔z���擾���܂��B
 public EcmItem[] GetItemsByValue(string colName, string dataValue)
 {
     DataRow[] rows = GetDataByValue(colName, dataValue);
     EcmItem[] result = new EcmItem[rows.Length];
     for(int i = 0; i < rows.Length; i++){
         result[i] = new EcmItem(rows[i]);
     }
     return result;
 }
Example #12
0
        // �i�荞�ݏ���ƃ\�[�g�����w�肵�āATable �ɑ����邷�ׂĂ� EcmItem ��擾���܂��B
        public EcmItem[] GetAllItems(string filterExpression, string sortColName, bool reverse)
        {
            if(this.Columns.Count == 0) return null;

            if(string.IsNullOrEmpty(sortColName) && string.IsNullOrEmpty(filterExpression)){
                return GetAllItems();
            }

            DataRow[] rows = null;
            if(string.IsNullOrEmpty(sortColName)){
                rows = this.Select(filterExpression);
            } else {
                if(reverse) sortColName += " DESC";
                rows = this.Select(filterExpression, sortColName);
            }

            EcmItem[] result = new EcmItem[rows.Length];
            for(int i = 0; i < rows.Length; i++){
                result[i] = new EcmItem(rows[i]);
            }
            return result;
        }
Example #13
0
 // Table �ɑ����邷�ׂĂ� EcmItem ��擾���܂��B
 public EcmItem[] GetAllItems()
 {
     DataRowCollection rows = this.Rows;
     EcmItem[] result = new EcmItem[rows.Count];
     for(int i = 0; i < rows.Count; i++){
         result[i] = new EcmItem(rows[i]);
     }
     return result;
 }
Example #14
0
 // public ���\�b�h
 // �^����ꂽ EcmItem �ɑΉ�����t�@�C���� Parse ���Ēu�����܂��B
 public abstract ProcessResult Process(EcmItem targetItem);
Example #15
0
 private XmlNode GetTable(EcmItem[] items)
 {
     return null;
 }