示例#1
0
        private void HandleMessage(string message)
        {
            receivedAnswer = Communication.Deserializer.Deserialize(message);

            if (receivedAnswer.MessageType == MESSAGE_TYPE.GET_MENU_CFM)
            {
            }

            if (receivedAnswer.MessageType == MESSAGE_TYPE.SEND_REPORT_CFM)
            {
                reportSender.SendReport(receivedAnswer.Message);
            }

            if (receivedAnswer.MessageType == MESSAGE_TYPE.SEND_ADVERTS_CFM)
            {
                List <AdvertisementDTG> advertsOnline = DeserializerClient.Deserializer.Deserialize_Adverts(receivedAnswer.Message);

                foreach (AdvertisementDTG advert in advertsOnline)
                {
                    if (advert.HourFrom <= DateTime.Now.Hour && advert.HourTo >= DateTime.Now.Hour)
                    {
                        this.AdvertText = advert.Text;
                    }
                }
            }
        }
示例#2
0
        private void SendRequestMessage(MESSAGE_TYPE messageType, List <string> value = null)
        {
            // value is a parameters separated by $
            CommunicationType cmd = new CommunicationType(messageType, "", value);

            switch (messageType)
            {
            case MESSAGE_TYPE.GET_MENU_REQ:
                socketConnection.SendAsync(Communication.Serializer.SerializeCommunicationType(cmd));
                break;

            case MESSAGE_TYPE.GET_ACTIVE_ORDERS_REQ:
                socketConnection.SendAsync(Communication.Serializer.SerializeCommunicationType(cmd));
                break;

            case MESSAGE_TYPE.GET_COMPLETED_ORDERS_REQ:
                socketConnection.SendAsync(Communication.Serializer.SerializeCommunicationType(cmd));
                break;

            case MESSAGE_TYPE.GET_ACTIVE_DELIVERIES_REQ:
                socketConnection.SendAsync(Communication.Serializer.SerializeCommunicationType(cmd));
                break;

            case MESSAGE_TYPE.GET_COMPLETED_DELIVERIES_REQ:
                socketConnection.SendAsync(Communication.Serializer.SerializeCommunicationType(cmd));
                break;

            case MESSAGE_TYPE.GET_ALL_CLIENTS_REQ:
                socketConnection.SendAsync(Communication.Serializer.SerializeCommunicationType(cmd));
                break;

            case MESSAGE_TYPE.GET_ORDER_BYID_REQ:
                socketConnection.SendAsync(Communication.Serializer.SerializeCommunicationType(cmd));
                break;

            case MESSAGE_TYPE.GET_DELIVERY_BYID_REQ:
                socketConnection.SendAsync(Communication.Serializer.SerializeCommunicationType(cmd));
                break;

            case MESSAGE_TYPE.CREATE_CLIENT_REQ:
                socketConnection.SendAsync(Communication.Serializer.SerializeCommunicationType(cmd));
                break;

            case MESSAGE_TYPE.CREATE_DISH_REQ:
                socketConnection.SendAsync(Communication.Serializer.SerializeCommunicationType(cmd));
                break;

            case MESSAGE_TYPE.CREATE_ORDER_REQ:
                socketConnection.SendAsync(Communication.Serializer.SerializeCommunicationType(cmd));
                break;

            case MESSAGE_TYPE.COMPLETE_ORDER_REQ:
                socketConnection.SendAsync(Communication.Serializer.SerializeCommunicationType(cmd));
                break;

            case MESSAGE_TYPE.COMPLETE_DELIVERY_REQ:
                socketConnection.SendAsync(Communication.Serializer.SerializeCommunicationType(cmd));
                break;
            }
        }
        public void OnNext(IncomeReport value)
        {
            lastReport = value;

            startDate = lastReport.StartDate.ToString();

            endDate = lastReport.EndDate.ToString();

            income = lastReport.Income.ToString();

            string toFile = "";

            toFile += "--------------------------" + Environment.NewLine;
            toFile += "Report start date: " + startDate + Environment.NewLine;
            toFile += "Report end date: " + endDate + Environment.NewLine;
            toFile += "Report income: " + income + Environment.NewLine;
            toFile += "--------------------------" + Environment.NewLine;

            CommunicationType cmd = new CommunicationType();

            cmd.MessageType = MESSAGE_TYPE.SEND_REPORT_CFM;
            cmd.Message     = toFile;
            socketConnection.SendAsync(Communication.Serializer.SerializeCommunicationType(cmd));
            //File.AppendAllText("IncomeReport.txt", toFile);
        }
示例#4
0
        private static bool deleteCommunicationType(CommunicationType communicationType)
        {
            SysDataAccessCredential dac = DAOUtility.GetSysCredentials();
            DataAccess das = new DataAccess();

            using (SqlConnection conn = new SqlConnection(DAOUtility.GetConnectionString(dac)))
            {
                conn.Open();

                SqlCommand command = new SqlCommand();
                command.Connection  = conn;
                command.CommandType = System.Data.CommandType.Text;
                command.CommandText = das.DELETE_COMMUNICATION_TYPE;
                command.Parameters.AddWithValue(CommunicationTypeDAO.AT_ID, communicationType.id);

                try
                {
                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            communicationType.id = DAOUtility.GetData <int>(reader, CommunicationTypeDAO.ID);
                        }
                    }
                }
                catch (Exception e)
                {
                    ErrorLogger.LogError(e, "DeleteCommunicationType()", communicationType.id.ToString());
                }
            }
            return(true);
        }
示例#5
0
        private static List <CommunicationType> getSingleCommunicationType(CommunicationType communicationType)
        {
            List <CommunicationType> communicationTypes = new List <CommunicationType>();
            SysDataAccessCredential  dac = DAOUtility.GetSysCredentials();
            DataAccess das = new DataAccess();

            using (SqlConnection conn = new SqlConnection(DAOUtility.GetConnectionString(dac)))
            {
                conn.Open();
                SqlCommand command = new SqlCommand();
                command.Connection  = conn;
                command.CommandType = System.Data.CommandType.Text;
                command.CommandText = das.GET_SINGLE_COMMUNICATION_TYPE;
                command.Parameters.AddWithValue(CommunicationTypeDAO.AT_ID, communicationType.id);

                try
                {
                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            communicationTypes.Add(new CommunicationType(reader));
                        }
                    }
                }
                catch (Exception e)
                {
                    ErrorLogger.LogError(e, "getSingleCommunicationType(CommunicationType CommunicationType)", communicationType.id.ToString());
                }
            }

            return(communicationTypes);
        }
示例#6
0
        protected bool SendMessage(CommunicationType communicationType, string content, int ttl = 3)
        {
            if (ttl < 0)
            {
                return(false);
            }
            byte[] type = BitConverter.GetBytes((int)communicationType);
            string data = SplitStr + content + SplitStr;

            byte[] buf = Encoding.UTF8.GetBytes(data);
            try
            {
                //if (tcpClient != null)
                //{
                //    tcpClient.Close();
                //    tcpClient = new TcpClient();
                //}
                tcpClient = ConnectSocket(RemoteEndPointIP, ShortMesPort);
                //tcpClient.Client.Send(buf);
                tcpClient.GetStream().Write(type, 0, type.Length);
                tcpClient.GetStream().Write(buf, 0, buf.Length);
                tcpClient.GetStream().Flush();
                //tc.Close();
                return(true);
            }
            catch (Exception ex)
            {
                EventPrint?.Invoke(ex.Message);
                return(SendMessage(communicationType, content, ttl - 1));
            }
        }
示例#7
0
        public async Task Check()
        {
            try
            {
                _logger.LogInfo($"Started fetching communication type: {_time.Now}");

                if (!await _internet.CheckForInternetConnectionAsync() || _session.SessionInformation.Offline)
                {
                    _logger.LogInfo($"Can connect to commuincation point: {_time.Now}");
                    return;
                }

                CommunicationType type = await _communication.GetCommunicationType();

                if (type != _communicationTypeService.GetCommunicationType())
                {
                    CommunicationType old = _communicationTypeService.GetCommunicationType();
                    _communicationTypeService.SetCommuncationType(type);
                    _notification.ShowStatusMessage(nameof(CommunicationTypeCheckBehaviour), $"Communication type changed from {old} to {type}");
                }

                _logger.LogInfo($"Finished fetching communication type: {_time.Now} | type is {type}");
            }
            catch (Exception e)
            {
                _logger.LogError(e);
            }
        }
示例#8
0
 public API(WebSocketConnection socketConnection)
 {
     this.reportSender               = new ReportSender();
     this.socketConnection           = socketConnection;
     this.socketConnection.onMessage = HandleMessage;
     this.receivedAnswer             = new CommunicationType();
 }
示例#9
0
        public static void Send(string message, bool error, CommunicationType type)
        {
            switch (type)
            {
            case CommunicationType.Console:
                Console.WriteLine((error ? "ERROR: " : "") + message);
                break;

            case CommunicationType.Dialog:
                if (error)
                {
                    Dialog.Error(message);
                }
                else
                {
                    Dialog.Message(message);
                }
                break;

            case CommunicationType.Notify:
                if (error)
                {
                    NotifyLoader.UpdateIcon(UpdateIconType.ShowBalloonError, message);
                }
                else
                {
                    NotifyLoader.UpdateIcon(UpdateIconType.ShowBaloonInfo, message);
                }
                break;
            }
        }
示例#10
0
 public void SetCommuncationType(CommunicationType type)
 {
     lock (_lock)
     {
         Type = type;
     }
 }
        private void 添加ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OprationSetting os = new OprationSetting();

            if (os.ShowDialog() == DialogResult.OK)
            {
                CommunicationType opType = CommunicationType.Com;
                if (os.CommunicationType.ToLower() == "tcp")
                {
                    opType = CommunicationType.TCP;
                }
                else if (os.CommunicationType.ToLower() == "udp")
                {
                    opType = CommunicationType.UDP;
                }
                else if (os.CommunicationType.ToLower() == "串口")
                {
                    opType = CommunicationType.Com;
                }

                DataType dType = DataType.Character;
                if (os.DataType.ToLower() == "十六进制")
                {
                    dType = DataType.Hex;
                }
                else if (os.DataType.ToLower() == "字符串")
                {
                    dType = DataType.Character;
                }

                UserOperation opration = new UserOperation(os.OprationName, opType, dType, os.Setting, os.Data, os.DelayTime);
                AddOpration(opration);
            }
        }
        private void UpdateCommunicationTypeUI(CommunicationType communicationType)
        {
            switch (communicationType)
            {
            case CommunicationType.RecipientPreference:
                DisplaySMS(true);
                DisplayEMail(true);
                DisplayPushNotification(false);
                break;

            case CommunicationType.Email:
                DisplayEMail(true);
                DisplaySMS(false);
                DisplayPushNotification(false);
                break;

            case CommunicationType.SMS:
                DisplaySMS(true);
                DisplayEMail(false);
                DisplayPushNotification(false);
                break;

            case CommunicationType.PushNotification:
                DisplaySMS(false);
                DisplayEMail(false);
                DisplayPushNotification(true);
                break;

            default:
                break;
            }
        }
        private void 开关电脑ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_opreations == null)
            {
                Helper.ShowMessageBox("提示", "请选择对应操作项或时间点!");
                return;
            }

            if (_relaySettings == null)
            {
                Helper.ShowMessageBox("提示", "继电器数据未添加!");
            }


            PcSwatch _pcSwitch = new PcSwatch(_relaySettings);

            if (_pcSwitch.ShowDialog() == DialogResult.OK)
            {
                CommunicationType opType = CommunicationType.Com;
                DataType          dType  = DataType.Hex;
                if (_pcSwitch.DataList.Count > 0)
                {
                    UserOperation OnOperation  = new UserOperation(_pcSwitch.OperationNameList[0], opType, dType, _pcSwitch.Setting, _pcSwitch.DataList[0], _pcSwitch.DelayTime);
                    UserOperation OffOperation = new UserOperation(_pcSwitch.OperationNameList[1], opType, dType, _pcSwitch.Setting, _pcSwitch.DataList[1], _pcSwitch.DelayTime);
                    AddOpration(OnOperation);
                    AddOpration(OffOperation);
                }
            }
        }
        /// <summary>
        /// 创建通讯模块
        /// </summary>
        /// <param name="communicationType">通讯方式</param>
        /// <returns></returns>
        public static ICommunication CreateCommunication(CommunicationType communicationType)
        {
            ICommunication communication = null;

            switch (communicationType)
            {
            case CommunicationType.C8962:
                communication = new C8962Communication();
                break;

            case CommunicationType.socketClient:
                communication = new SocketTcpClientCommunication();
                break;

            case CommunicationType.Http:
                communication = new HttpCommunication();
                break;

            case CommunicationType.HongDian:
                throw new NotImplementedException("CommunicationType.HongDian 通讯方式暂时未实现");

            //break;
            case CommunicationType.MAS:
                throw new NotImplementedException("CommunicationType.MAS 通讯方式暂时未实现");
            //break;

            default:
                throw new NotImplementedException("未知通讯方式");
                //break;
            }
            return(communication);
        }
示例#15
0
 public override void CanActorCommunicate(Actor actor, CommunicationType type, string message, Validation validation)
 {
     if (actor.User.AccessLevel != AccessLevel.Sysop && type == CommunicationType.Say)
     {
         validation.Fail("You open your mouth to speak, but the bishop casts a stern look at you, and you think it better to close your mouth.", null, nameof(RoomOfSilence));
     }
 }
示例#16
0
 public Communication()
 {
     ImpactedServices = new List <ImpactedService>();
     IsAlert          = false;
     IsExpanded       = false;
     CommType         = CommunicationType.ServiceIssue;
 }
        private async Task SendMessage(NotifyMessage content, CommunicationType communicationType)
        {
            var notificationsClient = new NotificationClient(_configuration.NotificationServiceApiKey);

            // Needs to be a dictionary<string,dynamic> for the client.....
            var personalisationDictionary = content.Personalisation.ToDictionary(x => x.Key, x => x.Value as dynamic);

            try
            {
                Logger.Info($"Sending communication request to Gov Notify");
                if (communicationType == CommunicationType.Email)
                {
                    var response = await notificationsClient.SendEmailAsync(content.To, content.Template, personalisationDictionary, content.Reference);
                }
                else if (communicationType == CommunicationType.Sms)
                {
                    var response = await notificationsClient.SendSmsAsync(content.To, content.Template, personalisationDictionary, content.Reference);
                }
            }
            catch (NotifyClientException notifyClientException)
            {
                Logger.Error(notifyClientException, $"Error sending communication {communicationType.ToString()} to Gov Notify with Gov.Notify Client");

                if (communicationType != CommunicationType.Sms || !SuppressSmsError(notifyClientException.Message))
                {
                    throw;
                }
            }
            catch (Exception exception)
            {
                Logger.Error(exception, $"Generic Error sending communication {communicationType.ToString()} to Gov Notify");
                throw;
            }
        }
/**
 *
 * TCP 服务器接收文件时发生
 *
 * */
        public static bool RcvFileFromClient(Socket client)
        {
            /*接受文件头*/

            //请求头
            CommunicationType cType = RcvOperationHeader(client);

            if (cType == CommunicationType.Send2Print)
            {
                //打印文件
                SendServerPermission(client);
                RcvFileRawData2Print(client);
            }
            else if (cType == CommunicationType.Send2Receive)
            {
                //发送文件
                SendServerPermission(client);
                RcvFileRawData2Save(client);
            }
            else if (cType == CommunicationType.GetPrinterListXml)
            {
                //客户获取打印机列表
                //发送本地打印机列表XML文件
                SendServerPermission(client);
                SendPrinterList(client);
            }
            else
            {
                // Debug.Assert(false);
            }

            /*返回客户端权限*/
            return(true);
        }
示例#19
0
 protected void gv_Result_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         e.Row.Cells[1].Text = CommunicationType.FindOne(CK.K["CommunicationTypeId"] == e.Row.Cells[1].Text).CommunicationTypeText;
     }
 }
示例#20
0
 public string SendMsg(Socket clientsocket, string mcMsg, CommunicationType ctype)
 {
     try
     {
         byte[] result = new byte[100];
         string s1     = null;
         int    receiveLength;
         if (ctype == 0)
         {
             clientsocket.Send(Encoding.ASCII.GetBytes(mcMsg));
             receiveLength = clientsocket.Receive(result);
             s1            = Encoding.ASCII.GetString(result, 0, receiveLength);
         }
         else
         {
             byte[] bytes = new byte[mcMsg.Length / 2];
             for (int i = 0; i < mcMsg.Length; i += 2)
             {
                 bytes[i / 2] = (byte)Convert.ToByte(mcMsg.Substring(i, 2), 16);
             }
             clientsocket.Send(bytes);
             receiveLength = clientsocket.Receive(result);
             for (int j = 0; j < receiveLength; j++)
             {
                 s1 += String.Format("{0:X2}", result[j]);
             }
         }
         return(s1);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(ex.ToString());
     }
 }
示例#21
0
        public override async Task Start()
        {
            PromptMessage("Authenticaiton process started", true);

            await RegisterSessionLocally();

            bool internetAvailable = await _internet.CheckForInternetConnectionAsync();

            if (!internetAvailable)
            {
                _session.SetMode(WorkMode.OFFLINE);
                PromptMessage("Internet access not available", true);
                PromptMessage("Starting work in offline mode", true);
            }
            else
            {
                await GetUserCredentials(); // Force user to enter valid credentials
            }

            //get communication type for server
            if (!_session.SessionInformation.Offline)
            {
                PromptMessage("Establishing communication type", true);
                CommunicationType type = await _communication.GetCommunicationType();

                _communicationTypeService.SetCommuncationType(type);
                PromptMessage($"Communication type {type}", true);
            }
            else
            {
                PromptMessage($"Communication type {_communicationTypeService.GetCommunicationType()}", true);
            }

            PromptMessage("Authenticaiton process finished", true);
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,CommunicationName,CommunicationSubType")] CommunicationType communicationType)
        {
            if (id != communicationType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(communicationType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CommunicationTypeExists(communicationType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(communicationType));
        }
示例#23
0
        private void EnsureEndpoints(CommunicationType processingCommunicationType)
        {
            var allEndpointsAreValid = true;
            var errorMessage         = new StringBuilder("Some endpoints are not valid:").AppendLine();
            var endpointMessagesDict = new Dictionary <Endpoint, string>();

            _log.WriteInfo(nameof(CqrsEngine), nameof(EnsureEndpoints), $"Endpoins verification for {processingCommunicationType}");

            foreach (var routeMap in new List <RouteMap> {
                DefaultRouteMap
            }.Concat(Contexts))
            {
                foreach (var route in routeMap)
                {
                    foreach (var messageRoute in route.MessageRoutes)
                    {
                        var routingKey = messageRoute.Key;
                        if (routingKey.CommunicationType != processingCommunicationType)
                        {
                            continue;
                        }

                        var endpoint = messageRoute.Value;
                        endpointMessagesDict[endpoint] =
                            $"Context {routeMap.Name}: "
                            + (processingCommunicationType == CommunicationType.Publish
                                ? $"publishing '{routingKey.MessageType.Name}' to"
                                : $"subscribing '{routingKey.MessageType.Name}' on")
                            + $" {endpoint}\t{{0}}";
                    }
                }
            }

            var endpointsErrorsDict = MessagingEngine.VerifyEndpoints(
                processingCommunicationType == CommunicationType.Publish ? EndpointUsage.Publish : EndpointUsage.Subscribe,
                endpointMessagesDict.Keys,
                _createMissingEndpoints);

            foreach (var endpointError in endpointsErrorsDict)
            {
                string messagePattern = endpointMessagesDict[endpointError.Key];
                if (string.IsNullOrWhiteSpace(endpointError.Value))
                {
                    _log.WriteInfo(nameof(CqrsEngine), nameof(EnsureEndpoints), string.Format(messagePattern, "OK"));
                }
                else
                {
                    _log.WriteError(
                        nameof(CqrsEngine),
                        nameof(EnsureEndpoints),
                        new InvalidOperationException(string.Format(messagePattern, $"ERROR: {endpointError.Value}")));
                }
            }

            if (!allEndpointsAreValid)
            {
                throw new ApplicationException(errorMessage.ToString());
            }
        }
        public CommunicationManager(IRabbitMQClient rabbitMQClient, CommunicationType communicationType, string queueName)
        {
            this.rabbitMQClient    = rabbitMQClient;
            this.communicationType = communicationType;
            this.queueName         = queueName;

            Initialize();
        }
示例#25
0
        public Task <Unit> Handle(ChangeTypeCommand request, CancellationToken cancellationToken)
        {
            CommunicationType type = (CommunicationType)Enum.ToObject(typeof(CommunicationType), request.Type);

            _service.SetCommuncationType(type);

            return(Task.FromResult(Unit.Value));
        }
示例#26
0
 protected virtual void ParseData(Socket socket, CommunicationType type, string content)
 {
     switch (type)
     {
     case CommunicationType.HeartbeatSend:
         break;
     }
 }
示例#27
0
        public MaplePacket(CommunicationType pType, ushort pOpcode)
        {
            Logger.PWrite("{0}[OUT]", Environment.NewLine);

            _memoryStream = new MemoryStream();
            _binWriter    = new BinaryWriter(_memoryStream);
            WriteByte((byte)pType);
            WriteUShort(pOpcode);
        }
示例#28
0
        public static CommunicationType createReceiverCommunicationType()
        {
            CommunicationType communication = new CommunicationType();

            communication.email         = RECEIVER_CONTACT_EMAIL;
            communication.contactPerson = RECEIVER_CONTACT_NAME;
            communication.phone         = RECEIVER_CONTACT_PHONE;
            return(communication);
        }
示例#29
0
        public MaplePacket(CommunicationType pType, ushort pOpcode)
        {
            Logger.PWrite("{0}[OUT]", Environment.NewLine);

            _memoryStream = new MemoryStream();
            _binWriter = new BinaryWriter(_memoryStream);
            WriteByte((byte)pType);
            WriteUShort(pOpcode);
        }
示例#30
0
        public static CommunicationType createShipperCommunicationType()
        {
            CommunicationType communication = new CommunicationType();

            communication.email         = SHIPPER_CONTACT_EMAIL;
            communication.contactPerson = SHIPPER_CONTACT_NAME;
            communication.phone         = SHIPPER_CONTACT_PHONE;
            return(communication);
        }
示例#31
0
 public void StartReceiveShortMessage(int port)
 {
     tcpListener = new TcpListener(IPAddress.Any, port);
     tcpListener.Start();
     byte[] splitByte = Encoding.UTF8.GetBytes(SplitStr);
     while (true)
     {
         try
         {
             Socket client = tcpListener.AcceptSocket();
             int    ttl    = TTL;
             byte[] buf    = new byte[0];
             int    offset;
             while (client.Available > 0 && ttl > 0)
             {
                 int    available = client.Available;
                 byte[] array     = new byte[available];
                 client.Receive(array, 0, array.Length, SocketFlags.None);
                 offset = buf.Length;
                 buf    = new byte[buf.Length + array.Length];
                 Array.Copy(array, 0, buf, offset, array.Length);
                 Thread.Sleep(WaitingTime);
                 ttl--;
             }
             byte[] temp = new byte[splitByte.Length];
             if (temp.Length < buf.Length)
             {
                 Array.Copy(buf, buf.Length - splitByte.Length, temp, 0, temp.Length);
                 bool canParse = true;
                 for (int i = 0; i < temp.Length; i++)
                 {
                     if (temp[i] != splitByte[i])
                     {
                         canParse = false;
                         break;
                     }
                 }
                 if (canParse)
                 {
                     byte[] byteType = BitConverter.GetBytes((int)CommunicationType.HeartbeatSend);// 4byte
                     Array.Copy(buf, 0, byteType, 0, byteType.Length);
                     byte[] conB = new byte[buf.Length - byteType.Length];
                     Array.Copy(buf, byteType.Length, conB, 0, conB.Length);
                     CommunicationType type    = (CommunicationType)BitConverter.ToInt32(byteType, 0);
                     string            data    = Encoding.UTF8.GetString(conB);
                     Regex             regex   = new Regex(SplitStr);
                     string            content = regex.Split(data)[1];
                     ParseData(client, type, content);
                 }
             }
         }
         catch (Exception ex)
         {
             EventPrint(ex.Message);
         }
     }
 }
示例#32
0
        /// <summary>
        /// Adds a new place to the petri net
        /// </summary>
        /// <param name="id">Unique identifier for the place (used in history)</param>
        /// <param name="type">The communication type of the place (e.g. input)</param>
        /// <exception cref="System.ArgumentException">If the place with the given <c>id</c> already exists or is empty</exception>
        /// <returns>The place</returns>
        public Place NewPlace(String id, CommunicationType type)
        {
            if (id == String.Empty)
            {
                throw new ArgumentException("Specified id cannot be empty");
            }

            Place place = new Place();
            place.Name = id;
            // Unique?
            Place p = Find(id);

            if (p != null)
            {
                throw new ArgumentException("Place with given id '{0}' already exists");
            }
            else
            {
                // Place Type
                place.Type = type;
                switch (type)
                {
                    case CommunicationType.Input:
                        inputPlaces.Add(place);
                        break;
                    case CommunicationType.Output:
                        outputPlaces.Add(place);
                        break;
                    default:
                        internalPlaces.Add(place);
                        break;
                }
                // History
                place.History.Push(id);

                return place;
            }
        }
示例#33
0
 public ProxomoApi(string applicationID, string proxomoAPIKey, string version, CommunicationType format = CommunicationType.JSON, bool validatessl = true, string url = "")
 {
     Init(applicationID, proxomoAPIKey, version, format, validatessl, url);
 }
示例#34
0
 public Communication(string name, string message, CommunicationType communicationType)
 {
     Name = name;
     Message = message;
     CommunicationType = communicationType;
 }
示例#35
0
 public UdpExchange(IPEndPoint endPoint, CommunicationType type)
 {
     _endPoint = endPoint;
     SetCommunicationTypeType(endPoint, type);
 }
示例#36
0
        public JsonResult SaveCommunication(int id, CommunicationType communicationType, string communicationDetails,
            string communicationSummary, string attachments)
        {
            this.associateService.SaveCommunication(
                new CommunicationHistoryModel
                {
                    AssociateId = id,
                    CommunicationType = communicationType,
                    Created = DateTime.Now,
                    Description = communicationSummary,
                    LoggedInUser = this.User.Identity.Name,
                    Details = communicationDetails
                }, attachments);

            return this.Json(true);
        }
示例#37
0
 private void SetCommunicationTypeType(IPEndPoint ep, CommunicationType type)
 {
     switch (type)
     {
         case CommunicationType.Multicast:
             _udpClient = GetMulticastClient(ep);
             break;
         default:
             throw new NotSupportedException("CommunicationType");
     }
 }
 public ChangeValue(Guid communicationId, CommunicationType communicationType, string value) : base(communicationId)
 {
     CommunicationId = communicationId;
     CommunicationType = communicationType;
     Value = value;
 }
示例#39
0
        private string GetCommunicationTypeName(CommunicationType objCommType)
        {
            string strCommTypeName = Convert.ToString(objCommType);
            switch ((CommunicationType)objCommType)
            {
                case CommunicationType.Absence:
                    strCommTypeName="Absence";
                    break;
                case CommunicationType.Call:
                    strCommTypeName="Call"; break;
                case CommunicationType.Email:
                    strCommTypeName="Email"; break;
                case CommunicationType.Expense:
                    strCommTypeName="Expense"; break;
                case CommunicationType.Note:
                    strCommTypeName="Note"; break;
                case CommunicationType.SMS:
                    strCommTypeName="SMS"; break;
                case CommunicationType.Status:
                    strCommTypeName="Status"; break;
                case CommunicationType.Timesheet:
                    strCommTypeName="Timesheet"; break;

                default:
                    if (Convert.ToInt32(objCommType) == 0)
                        strCommTypeName = "Emails";
                    else
                        strCommTypeName = Convert.ToString(objCommType);
                    break;
            }
            return strCommTypeName;
        }
示例#40
0
 private void btnVirtualComPort_Click(object sender, EventArgs e)
 {
     _cType = CommunicationType.VirtualCom;
     OpenComPort();
 }
示例#41
0
        private void Init(string applicationID, string proxomoAPIKey, string version, CommunicationType format, bool validatessl, string url)
        {
            APIVersion = version;
            _applicationID = applicationID;
            _proxomoAPIKey = proxomoAPIKey;
            this.ValidateSSLCert = validatessl;
            this.Format = format;

            if (format == CommunicationType.XML)
            {
                contentType = "text/xml";

                if (String.IsNullOrWhiteSpace(url))
                {
                    baseURL = String.Format("https://service.proxomo.com/{0}/xml", APIVersion);
                }
                else
                {
                    baseURL = String.Format("{0}/{1}/xml", url, APIVersion);
                }
            }
            else if (format == CommunicationType.JSON)
            {
                contentType = "application/json";

                if (String.IsNullOrWhiteSpace(url))
                {
                    baseURL = string.Format("https://service.proxomo.com/{0}/json", APIVersion);
                }
                else
                {
                    baseURL = String.Format("{0}/{1}/json", url, APIVersion);
                }
            }

            GetAuthToken();
        }
 public bool Communication(string name, string message, CommunicationType communicationType)
 {
     return Send(new Communication(name, message, communicationType));
 }
示例#43
0
 public Communicate(string to, CommunicationType communicationType, string message)
 {
     To = to;
     CommunicationType = communicationType;
     Message = message;
 }
示例#44
0
 public void CreateCommunicationsHistoryItem(int associateId, CommunicationType type, string description, string loggedInUser, string details)
 {
     this.MomentaDb.CreateCommunicationsHistoryItem(associateId, (byte)type, description, loggedInUser, details);
 }