Beispiel #1
0
 private bool IsExist(SocketOutChannel ch, string fieldname)
 {
     foreach (SocketOutQueryResultItem item in ch.Rule.QueryResult.MappingList)
     {
         if (item.TargetField == fieldname)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #2
0
        private void InsertDataDT(SocketOutChannel chn)
        {
            SocketOutQueryResultItem item = new SocketOutQueryResultItem();

            item.ThirdPartyDBPatamter.FieldName = "";
            item.TargetField   = "data_dt";
            item.GWDataDBField = GWDataDBField.i_DataDateTime;
            item.SourceField   = item.GWDataDBField.FieldName;

            chn.Rule.QueryResult.MappingList.Add(item);
        }
Beispiel #3
0
        public FChannel(FSocketOutConfiguration frm, XCollection <SocketOutChannel> channels)
        {
            InitializeComponent();
            parentForm   = frm;
            channelSet   = channels;
            type         = "Add";
            channel      = new SocketOutChannel();
            criteriaList = new XCollection <SocketOutQueryCriterialItem>();
            resultList   = new XCollection <SocketOutQueryResultItem>();

            this.Text = "Add Channel";
            GetChannelNameSet(channels);
        }
Beispiel #4
0
        public FChannel(FSocketOutConfiguration frm, XCollection <SocketOutChannel> channels, int index)
        {
            InitializeComponent();
            parentForm   = frm;
            channelSet   = channels;
            type         = "Edit";
            channel      = channels[index];
            channelIndex = index;
            criteriaList = channel.Rule.QueryCriteria.MappingList;
            resultList   = channel.Rule.QueryResult.MappingList;

            this.Text = "Edit Channel";
            GetChannelNameSet(channels);
            ShowChannel();
        }
Beispiel #5
0
        /// <summary>
        /// Copy Channel
        /// </summary>
        /// <param name="frm"></param>
        /// <param name="channels"></param>
        /// <param name="copyChannel"></param>
        public FChannel(FSocketOutConfiguration frm, XCollection <SocketOutChannel> channels, SocketOutChannel copyChannel)
        {
            InitializeComponent();
            parentForm = frm;
            channelSet = channels;
            type       = "Add";

            channel      = copyChannel;
            criteriaList = channel.Rule.QueryCriteria.MappingList;
            resultList   = channel.Rule.QueryResult.MappingList;

            this.Text = "Add Channel";
            GetChannelNameSet(channels);
            ShowChannel();
        }
Beispiel #6
0
        private void btnChannelCopy_Click(object sender, EventArgs e)
        {
            int count = channelSet.Count;

            SocketOutChannel copyChannel = channelSet[channelIndex].Clone();

            copyChannel.ChannelName += "_copy";

            FChannel frm = new FChannel(this, channelSet, copyChannel);

            frm.ShowDialog(pMain);

            if (channelSet.Count > count)
            {  // Add successfully
                channelIndex = count;
                lstvChannel.Items[channelIndex].Selected = true;
            }
        }
Beispiel #7
0
        private void SendCommand2Server(SocketOutChannel ch, DataSet ds)
        {
            CommandSendData csd = new CommandSendData();

            PacketHead ph = new PacketHead();

            ph.PacketType      = CommandSendData.PacketType;
            ph.DestinationIP   = SocketOutboundAdapterConfigMgt.SocketOutAdapterConfig.ClientSocketParams.ServerIP;
            ph.DestinationPort = SocketOutboundAdapterConfigMgt.SocketOutAdapterConfig.ClientSocketParams.ServerPort;
            ph.SourceIP        = SocketOutboundAdapterConfigMgt.SocketOutAdapterConfig.ClientSocketParams.CallbackIP;
            ph.SourcePort      = SocketOutboundAdapterConfigMgt.SocketOutAdapterConfig.ClientSocketParams.CallbackPort;

            csd.PacketHead = ph;


            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                csd.Params.Clear();
                csd.CommandGUID = "";

                foreach (SocketOutQueryResultItem item in ch.Rule.QueryResult.MappingList)
                {
                    //string TargetField = item.ThirdPartyDBPatamter.FieldName.Trim();
                    string TargetField = item.TargetField.Trim();
                    if (TargetField == "")
                    {
                        continue;
                    }

                    if (TargetField.ToUpper() == ("CommandGUID").ToUpper())
                    {
                        csd.CommandGUID = dr[TargetField].ToString();
                        continue;
                    }
                    if (TargetField.ToUpper().ToUpper() == ("Commandtype").ToUpper())
                    {
                        csd.CommandType = (CommandBase.CommandTypeEnum)Convert.ToInt32(dr[TargetField].ToString());
                        continue;
                    }

                    if (ds.Tables[0].Columns.IndexOf(TargetField) < 0)
                    {
                        Program.Log.Write(LogType.Error, TargetField + " is not exist in dataset!\r\n");
                    }
                    else
                    {
                        csd.Params.Add(TargetField, dr[TargetField].ToString());
                    }
                }

                if (csd.CommandGUID == null || csd.CommandGUID.Trim() == "")
                {
                    csd.CommandGUID = Guid.NewGuid().ToString();
                }

                //byte[] result = _ClientSocket.SendMsg(csd.EncodePackage());
                string result = this.SendMsgToServer(csd);

                if (result != null)
                {
                    CommandRespSendData crsd = new CommandRespSendData();
                    crsd.DecodePackagea(result);
                    if (OnDataDischarge != null)
                    {
                        OnDataDischarge(new string[] { dr["Data_ID"].ToString() });
                    }
                    Program.Log.Write(LogType.Error, "SendMsg Success! SendResult= " + crsd.SendResult + "\r\n");


                    //if (crsd.SendResult == "1")
                    //{
                    //    if (OnDataDischarge != null)
                    //        OnDataDischarge(new string[] { dr["Data_ID"].ToString() });
                    //    Program.Log.Write(LogType.Debug, "SendMsg Success! SendResult=1\r\n");
                    //}
                    //else //2007-3-9 Add: Send success, Set Processflag =1, and write a log
                    //{
                    //    if (OnDataDischarge != null)
                    //        OnDataDischarge(new string[] { dr["Data_ID"].ToString() });
                    //    Program.Log.Write(LogType.Error, "SendMsg Success! SendResult= " + crsd.SendResult + "\r\n");
                    //}
                }
                else
                {
                    Program.Log.Write(LogType.Error, "SendMsg Failure!\r\n");
                }
            }
        }