コード例 #1
0
        public FileOutChannel Clone()
        {
            FileOutChannel ch = new FileOutChannel();

            ch.ChannelName = this.ChannelName;

            ch.Enable = this.Enable;

            ch.OperationName = this.OperationName;

            //ch.Rule.RuleID = Rule.RuleID;     //do not copy RuleID
            ch.Rule.RuleName              = Rule.RuleName;
            ch.Rule.MaxRecordCount        = Rule.MaxRecordCount;
            ch.Rule.CheckProcessFlag      = Rule.CheckProcessFlag;
            ch.Rule.AutoUpdateProcessFlag = Rule.AutoUpdateProcessFlag;

            ch.Rule.QueryCriteria.Type         = Rule.QueryCriteria.Type;
            ch.Rule.QueryCriteria.SQLStatement = Rule.QueryCriteria.SQLStatement;

            //ch.Rule.QueryCriteriaRuleType = this.Rule.QueryCriteriaRuleType;
            foreach (FileOutQueryCriterialItem item in Rule.QueryCriteria.MappingList)
            {
                FileOutQueryCriterialItem i = item.Clone();
                ch.Rule.QueryCriteria.MappingList.Add(i);
            }
            foreach (FileOutQueryResultItem item in Rule.QueryResult.MappingList)
            {
                FileOutQueryResultItem i = item.Clone();
                ch.Rule.QueryResult.MappingList.Add(i);
            }

            return(ch);
        }
コード例 #2
0
        /// <summary>
        /// support [%ChannelName%] token, let channecl.name as the part of filename
        /// </summary>
        /// <param name="ch"></param>
        /// <returns></returns>
        public static string BuildOutFileName(FileOutChannel ch, DataRow dr)
        {
            if (_FileOutAdapterConfig == null)
            {
                throw new Exception("System cannot initialized!");
            }

            string sFilePath   = _FileOutAdapterConfig.OutGeneralParams.FilePath;
            string sFilePrefix = _FileOutAdapterConfig.OutGeneralParams.FilePrefix;
            string sFileSuffix = _FileOutAdapterConfig.OutGeneralParams.FileSuffix;

            string sDatetime = "";

            if (_FileOutAdapterConfig.OutGeneralParams.FileDtFormat.Trim() != "")
            {
                sDatetime = DateTime.Now.ToString(_FileOutAdapterConfig.OutGeneralParams.FileDtFormat);
            }


            if (sFilePath.Trim() == "")
            {
                sFilePath = Application.StartupPath + "\\data\\";
            }
            if (!Directory.Exists(sFilePath))
            {
                Directory.CreateDirectory(sFilePath);
            }

            sFilePath = sFilePath.Trim();
            if (sFilePath.Substring(sFilePath.Length - 1, 1) != "\\")
            {
                sFilePath = sFilePath + "\\";
            }

            #region Replace [%Table_Field%] with pValue
            //if (sFilePrefix.Trim().ToUpper() == ("[%ChannelName%]").ToUpper())
            //    sFilePrefix = ch.ChannelName;
            string pValue;   //replace value
            foreach (GWDataDBField prefield in FileOutAdapterConfig.OutGeneralParams.PreGWDataDBFields)
            {
                pValue = "";
                foreach (FileOutQueryResultItem resultItem in ch.Rule.QueryResult.MappingList)
                {
                    GWDataDBField resultField = resultItem.GWDataDBField;
                    if (resultField.GetFullFieldName().Trim().ToUpper() == prefield.GetFullFieldName().Trim().ToUpper())
                    {
                        object o = dr[resultItem.TargetField];
                        if (Convert.IsDBNull(o))
                        {
                            pValue = "";
                        }
                        else
                        {
                            pValue = Convert.ToString(o);
                        }
                        break;
                    }
                }

                //Replace [%Table_Field%] with pValue
                sFilePrefix = sFilePrefix.Replace("[%" + prefield.GetFullFieldName().Replace(".", "_") + "%]", pValue);
            }

            //Gurant no error file name
            sFilePrefix = sFilePrefix.Replace("[%", "");
            sFilePrefix = sFilePrefix.Replace("%]", "");
            #endregion

            if (sFileSuffix.IndexOf(".") < 0)
            {
                sFileSuffix = "." + sFileSuffix;
            }

            string sFileName;
            for (int i = 0; i < Int32.MaxValue; i++)
            {
                if (i == 0)
                {
                    sFileName = sFilePath + sFilePrefix + sDatetime + sFileSuffix;
                }
                else
                {
                    sFileName = sFilePath + sFilePrefix + sDatetime + i.ToString() + sFileSuffix;
                }

                if (!File.Exists(sFileName))
                {
                    return(sFileName);
                }
            }
            throw new Exception("Cannot build outfilename, extract out int32.maxvalue!");
        }
コード例 #3
0
        public static FileOutChannel BuildReportChannel()
        {
            FileOutChannel ch = new FileOutChannel();

            #region General
            ch.ChannelName   = "CH_REPORT";
            ch.Enable        = true;
            ch.OperationName = "";

            ch.Rule.AutoUpdateProcessFlag = true;
            ch.Rule.CheckProcessFlag      = true;
            ch.Rule.RuleID             = "CH_REPORT";
            ch.Rule.RuleName           = "CH_REPORT";
            ch.Rule.QueryCriteria.Type = QueryCriteriaRuleType.DataSet;
            #endregion

            #region Critera
            FileOutQueryCriterialItem ci = new FileOutQueryCriterialItem();
            ci.Operator      = QueryCriteriaOperator.Equal;
            ci.Type          = QueryCriteriaType.Or;
            ci.TargetField   = "F_INDEX_EVENT_TYPE";
            ci.SourceField   = "EVENT_TYPE";
            ci.GWDataDBField = GWDataDBField.i_EventType.Clone();

            ci.Translating.Type = TranslatingType.FixValue;
            ci.Singal           = QueryCriteriaSignal.None;
            ci.RedundancyFlag   = false;

            ci.ThirdPartyDBPatamter.FieldID = 1;
            ci.Translating.ConstValue       = "30";
            ch.Rule.QueryCriteria.MappingList.Add(ci);

            //CRITERIA
            ci               = new FileOutQueryCriterialItem();
            ci.Operator      = QueryCriteriaOperator.Equal;
            ci.Type          = QueryCriteriaType.Or;
            ci.TargetField   = "F_INDEX_EVENT_TYPE";
            ci.SourceField   = "EVENT_TYPE";
            ci.GWDataDBField = GWDataDBField.i_EventType.Clone();

            ci.Translating.Type = TranslatingType.FixValue;
            ci.Singal           = QueryCriteriaSignal.None;
            ci.RedundancyFlag   = false;

            ci.ThirdPartyDBPatamter.FieldID = 2;
            ci.Translating.ConstValue       = "31";
            ch.Rule.QueryCriteria.MappingList.Add(ci);

            //CRITERIA
            ci               = new FileOutQueryCriterialItem();
            ci.Operator      = QueryCriteriaOperator.Equal;
            ci.Type          = QueryCriteriaType.Or;
            ci.TargetField   = "F_INDEX_EVENT_TYPE";
            ci.SourceField   = "EVENT_TYPE";
            ci.GWDataDBField = GWDataDBField.i_EventType.Clone();

            ci.Translating.Type = TranslatingType.FixValue;
            ci.Singal           = QueryCriteriaSignal.None;
            ci.RedundancyFlag   = false;

            ci.ThirdPartyDBPatamter.FieldID = 3;
            ci.Translating.ConstValue       = "32";
            ch.Rule.QueryCriteria.MappingList.Add(ci);

            //CRITERIA
            ci               = new FileOutQueryCriterialItem();
            ci.Operator      = QueryCriteriaOperator.Equal;
            ci.Type          = QueryCriteriaType.Or;
            ci.TargetField   = "F_INDEX_EVENT_TYPE";
            ci.SourceField   = "EVENT_TYPE";
            ci.GWDataDBField = GWDataDBField.i_EventType.Clone();

            ci.Translating.Type = TranslatingType.FixValue;
            ci.Singal           = QueryCriteriaSignal.None;
            ci.RedundancyFlag   = false;

            ci.ThirdPartyDBPatamter.FieldID = 4;
            ci.Translating.ConstValue       = "33";
            ch.Rule.QueryCriteria.MappingList.Add(ci);
            #endregion

            #region Result Index
            int iFieldID = 0;
            foreach (GWDataDBField f in GWDataDBField.GetFields(GWDataDBTable.Index))
            {
                if (f.GetFullFieldName() == GWDataDBField.i_IndexGuid.GetFullFieldName())
                {
                    continue;
                }
                if (f.GetFullFieldName() == GWDataDBField.i_DataDateTime.GetFullFieldName())
                {
                    continue;
                }
                if (f.GetFullFieldName() == GWDataDBField.i_PROCESS_FLAG.GetFullFieldName())
                {
                    continue;
                }


                //Result
                FileOutQueryResultItem ri = new FileOutQueryResultItem();
                ri.Translating.Type = TranslatingType.None;
                ri.RedundancyFlag   = false;

                ri.ThirdPartyDBPatamter.SectionName   = "F_INDEX";
                ri.ThirdPartyDBPatamter.FieldID       = ++iFieldID;
                ri.ThirdPartyDBPatamter.FieldName     = f.FieldName.ToUpper();
                ri.ThirdPartyDBPatamter.FieldType     = System.Data.OleDb.OleDbType.VarChar;
                ri.ThirdPartyDBPatamter.FileFieldFlag = false;
                ri.TargetField = f.GetFullFieldName().ToUpper().Replace(".", "_");

                ri.GWDataDBField = f.Clone();
                ri.SourceField   = f.GetFullFieldName().ToUpper().Replace(".", "_");
                ch.Rule.QueryResult.MappingList.Add(ri);
            }
            #endregion

            #region Result Patient
            iFieldID = 0;
            foreach (GWDataDBField f in GWDataDBField.GetFields(GWDataDBTable.Patient))
            {
                if (f.GetFullFieldName() == GWDataDBField.p_DATA_ID.GetFullFieldName())
                {
                    continue;
                }
                if (f.GetFullFieldName() == GWDataDBField.p_DATA_DT.GetFullFieldName())
                {
                    continue;
                }
                //Result
                FileOutQueryResultItem ri = new FileOutQueryResultItem();
                ri.Translating.Type = TranslatingType.None;
                ri.RedundancyFlag   = false;
                ri.SourceField      = f.GetFullFieldName().ToUpper().Replace(".", "_");

                ri.ThirdPartyDBPatamter.SectionName   = "F_PATIENT";
                ri.ThirdPartyDBPatamter.FieldID       = ++iFieldID;
                ri.ThirdPartyDBPatamter.FieldName     = f.FieldName.ToUpper();
                ri.ThirdPartyDBPatamter.FieldType     = System.Data.OleDb.OleDbType.VarChar;
                ri.ThirdPartyDBPatamter.FileFieldFlag = false;
                ri.TargetField = f.GetFullFieldName().ToUpper().Replace(".", "_");

                ri.GWDataDBField = f.Clone();
                ri.SourceField   = f.GetFullFieldName().ToUpper().Replace(".", "_");
                ch.Rule.QueryResult.MappingList.Add(ri);
            }
            #endregion

            #region Result Order
            iFieldID = 0;
            foreach (GWDataDBField f in GWDataDBField.GetFields(GWDataDBTable.Order))
            {
                if (f.GetFullFieldName() == GWDataDBField.o_DATA_ID.GetFullFieldName())
                {
                    continue;
                }
                if (f.GetFullFieldName() == GWDataDBField.o_DATA_DT.GetFullFieldName())
                {
                    continue;
                }

                //Result
                FileOutQueryResultItem ri = new FileOutQueryResultItem();
                ri.Translating.Type = TranslatingType.None;
                ri.RedundancyFlag   = false;

                ri.SourceField = f.GetFullFieldName().ToUpper().Replace(".", "_");
                ri.ThirdPartyDBPatamter.SectionName   = "F_ORDER";
                ri.ThirdPartyDBPatamter.FieldID       = ++iFieldID;
                ri.ThirdPartyDBPatamter.FieldName     = f.FieldName.ToUpper();
                ri.ThirdPartyDBPatamter.FieldType     = System.Data.OleDb.OleDbType.VarChar;
                ri.ThirdPartyDBPatamter.FileFieldFlag = false;
                ri.TargetField = f.GetFullFieldName().ToUpper().Replace(".", "_");

                ri.GWDataDBField = f.Clone();
                ri.SourceField   = f.GetFullFieldName().ToUpper().Replace(".", "_");
                ch.Rule.QueryResult.MappingList.Add(ri);
            }
            #endregion

            #region Result Order
            iFieldID = 0;
            foreach (GWDataDBField f in GWDataDBField.GetFields(GWDataDBTable.Report))
            {
                if (f.GetFullFieldName() == GWDataDBField.r_DATA_ID.GetFullFieldName())
                {
                    continue;
                }
                if (f.GetFullFieldName() == GWDataDBField.r_DATA_DT.GetFullFieldName())
                {
                    continue;
                }

                //Result
                FileOutQueryResultItem ri = new FileOutQueryResultItem();
                ri.Translating.Type = TranslatingType.None;
                ri.RedundancyFlag   = false;

                ri.SourceField = f.GetFullFieldName().ToUpper().Replace(".", "_");
                ri.ThirdPartyDBPatamter.SectionName   = "F_REPORT";
                ri.ThirdPartyDBPatamter.FieldID       = ++iFieldID;
                ri.ThirdPartyDBPatamter.FieldName     = f.FieldName.ToUpper();
                ri.ThirdPartyDBPatamter.FieldType     = System.Data.OleDb.OleDbType.VarChar;
                ri.ThirdPartyDBPatamter.FileFieldFlag = false;
                ri.TargetField = f.GetFullFieldName().ToUpper().Replace(".", "_");

                ri.GWDataDBField = f.Clone();
                ri.SourceField   = f.GetFullFieldName().ToUpper().Replace(".", "_");
                ch.Rule.QueryResult.MappingList.Add(ri);
            }
            #endregion

            return(ch);
        }