Beispiel #1
0
        /// <summary>
        /// 方法说明:通过SDK发送自定义消息接口:[支持4000-9999的自定义消息,仅仅是传输][完成自定义消息(MsCustomEntity)中的content内容]
        /// 完成时间:2017-05-16
        /// </summary>
        /// <param name="entity">发送消息实体</param>
        /// <param name="custommsgType">自定义消息类型[4000-9999]</param>
        /// <param name="customTopic">自定义主题</param>
        /// <param name="errorMsg">提示信息</param>
        /// <returns>是否成功发送消息</returns>
        public bool SdkPublishCustomMsg(MsSdkCustomEntity entity, int custommsgType, string customTopic,
                                        ref string errorMsg)
        {
            var jsonStr = MsgConverter.GetJsonByCustomMsg(entity, custommsgType.ToString(), ref errorMsg);

            return(!string.IsNullOrEmpty(jsonStr) && Publish(customTopic, jsonStr, false, ref errorMsg));
        }
Beispiel #2
0
        /// <summary>
        /// 方法说明:SDK发送群阅后即焚消息[群主改变阅后即焚状态]
        /// 完成时间:2015-05-16
        /// </summary>
        /// <param name="changeMode">要切换的阅后即焚状态</param>
        /// <param name="sendmodeEntity">发送实体信息</param>
        /// <param name="errorMsg">错误提示</param>
        /// <returns>是否成功发送群阅后即焚消息</returns>
        public bool SdkPublishGpOwnerChangeMode(GroupChangeMode changeMode, MsSdkMessageChat sendmodeEntity,
                                                ref string errorMsg)
        {
            var jsonStr = MsgConverter.GetJsonByGroupChangeMode(sendmodeEntity, changeMode, ref errorMsg);

            return(!string.IsNullOrEmpty(jsonStr) && Publish(TopicSend.sdk_send.ToString(), jsonStr, false, ref errorMsg));
        }
Beispiel #3
0
        async Task StartReceiveMessages(WebSocket socket)
        {
            while (socket.State == WebSocketState.Open)
            {
                var(response, message) = await ReadFullMessage(socket, CancellationToken.None);

                if (response.MessageType == WebSocketMessageType.Close)
                {
                    break;
                }
                else
                {
                    var msg = MsgConverter.FromJsonByteArray <WebSocketRequest>(message);
                    await Task.Delay(TimeSpan.FromSeconds(0.1));

                    var msgResponse = new WebSocketResponse
                    {
                        CorrelationId = msg.CorrelationId,
                        ResponseType  = ResponseType.Pong
                    };
                    var bytes = MsgConverter.ToJsonByteArray(msgResponse);
                    await socket.SendAsync(bytes, WebSocketMessageType.Text, true, CancellationToken.None);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 方法说明:SDK发送终端消息接口:心跳消息、请求离线消息
        /// 完成时间:2017-05-16
        /// </summary>
        /// <param name="entity">发送消息实体</param>
        /// <param name="errorMsg">提示信息</param>
        /// <returns>是否成功发送消息</returns>
        public bool SdkPublishTerminalMsg <T>(T entity, ref string errorMsg) where T : SdkMsTerminalBase
        {
            var isheartBeat = false;
            var jsonStr     = MsgConverter.GetJsonByTerminalMsg <T>(entity, ref isheartBeat, ref errorMsg);

            return(!string.IsNullOrEmpty(jsonStr) &&
                   Publish(TopicSend.sdk_user.ToString(), jsonStr, isheartBeat, ref errorMsg));
        }
Beispiel #5
0
        public static void Run()
        {
            var url = "ws://localhost:5000";
            var concurrentCopies = 50;

            var webSocketsPool = ConnectionPool.Create(
                name: "webSocketsPool",
                connectionsCount: concurrentCopies,
                openConnection: (number) =>
            {
                var ws = new ClientWebSocket();
                ws.ConnectAsync(new Uri(url), CancellationToken.None).Wait();
                return(ws);
            },
                closeConnection: (connection) =>
            {
                connection.CloseAsync(WebSocketCloseStatus.NormalClosure, "", CancellationToken.None)
                .Wait();
            }
                );

            var pingStep = Step.Create("ping", webSocketsPool, async context =>
            {
                var msg = new WebSocketRequest
                {
                    CorrelationId = context.CorrelationId.Id,
                    RequestType   = RequestType.Ping
                };
                var bytes = MsgConverter.ToJsonByteArray(msg);
                await context.Connection.SendAsync(bytes, WebSocketMessageType.Text, true, context.CancellationToken);
                return(Response.Ok());
            });

            var pongStep = Step.Create("pong", webSocketsPool, async context =>
            {
                while (true)
                {
                    var(response, message) = await WebSocketsMiddleware.ReadFullMessage(context.Connection, context.CancellationToken);
                    var msg = MsgConverter.FromJsonByteArray <WebSocketResponse>(message);

                    if (msg.CorrelationId == context.CorrelationId.Id)
                    {
                        return(Response.Ok(msg));
                    }
                }
            });

            var scenario = ScenarioBuilder
                           .CreateScenario("web_socket test", new[] { pingStep, pongStep })
                           .WithOutWarmUp()
                           .WithLoadSimulations(new[]
            {
                Simulation.KeepConcurrentScenarios(concurrentCopies, during: TimeSpan.FromSeconds(10))
            });

            NBomberRunner.RegisterScenarios(scenario)
            .RunInConsole();
        }
Beispiel #6
0
        /// <summary>
        /// 方法说明:通过SDK发送自定义消息接口:[支持4000-9999的自定义消息已读/收回执,仅仅是传输][完成自定义消息(MsCustomEntity)中的content内容]
        /// 完成时间:2017-05-16
        /// </summary>
        /// <param name="sendReceipt">已读/收回执实体</param>
        /// <param name="receiptType">已读/收类型</param>
        /// <param name="customTopic">自定义消息主题</param>
        /// <param name="errorMsg">提示信息</param>
        /// <returns>是否成功发送消息</returns>
        public bool SdkPublishCustomReceiptMsg(SdkMsSendMsgReceipt sendReceipt,
                                               SdkReceiptType receiptType, string customTopic, ref string errorMsg)
        {
            var jsonStr = MsgConverter.GetJsonByMsgReceipt(sendReceipt, ref errorMsg);
            var topic   = receiptType == SdkReceiptType.ReadReceipt
                ? TopicSend.sdk_read.ToString()
                : TopicSend.sdk_receive.ToString();

            return(!string.IsNullOrEmpty(jsonStr) && Publish(topic, jsonStr, false, ref errorMsg));
        }
Beispiel #7
0
        /// <summary>
        /// Klasa testująca poprawność biblioteki klas XMLmsg
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            // stworzenie list pomocnicznych trzymających wartości własności obiektów klasy Msg w postaci stringa
            List <string> nwLista  = new List <string>();
            List <string> nnwLista = new List <string>();
            // stworzenie przykładowego obiektu Msg
            Msg nw = new Msg()
            {
                Komenda   = Command.Login.ToString(),
                Nadawca   = "J",
                Odbiorca  = "T",
                Wiadomosc = "PIWO"
            };

            // wypisanie pierwszego obiektu
            Console.WriteLine("Jaka komenda: {0}, kto wysyła: {1}, kto odbiera: {2}, jaka tresc: {3}", nw.Komenda, nw.Nadawca, nw.Odbiorca, nw.Wiadomosc);
            MsgConverter mConv = new MsgConverter();

            // konwersja pierwszego obiektu do bytów
            byte[] bajty = mConv.doByte(nw);
            // odkodowanie pierwszego obiektu i stworzenie identycznego drugiego
            Msg nnw = mConv.doMsg(bajty);

            //wypisanie drugiego obiektu
            Console.WriteLine("Jaka komenda: {0}, kto wysyła: {1}, kto odbiera: {2}, jaka tresc: {3}", nnw.Komenda, nnw.Nadawca, nnw.Odbiorca, nnw.Wiadomosc);

            var s = nw;
            // w foreachu wpisanie jako stringi wartości wszystkich własności obiektu pierwszego
            string temp;

            foreach (var p in s.GetType().GetProperties().Where(p => p.GetGetMethod().GetParameters().Count() == 0))
            {
                temp = p.GetValue(s, null) != null?p.GetValue(s, null).ToString() : "null";

                nwLista.Add(temp);
                //Console.WriteLine(p.GetValue(s, null));
            }
            // w foreachu wpisanie jako stringi wartości wszystkich własności obiektu drugiego
            s = nnw;
            foreach (var p in s.GetType().GetProperties().Where(p => p.GetGetMethod().GetParameters().Count() == 0))
            {
                temp = p.GetValue(s, null) != null?p.GetValue(s, null).ToString() : "null";

                nnwLista.Add(temp);
            }


            // porownanie obydwu list, jeżeli wszystkie wartości są identyczne oba obiekty są identyczne
            string str = czyIdentyczne(nwLista, nnwLista) ? "TEST POPRAWNY - OBIE KLASY CHYBA SĄ IDENTYCZNE!" : "TEST BŁĘDNY!";

            Console.WriteLine("{0}", str);
            Console.ReadKey(true);
        }
Beispiel #8
0
        /// <summary>
        /// 方法说明:接收其他信息方法
        /// 完成时间:2017-05-10
        /// </summary>
        /// <param name="msReceived">接收消息注册</param>
        /// <param name="msType">群组消息类型</param>
        /// <param name="mqArray">群组消息内容</param>
        /// <param name="errorMsg">错误提示</param>
        private static void HandleOtherMsReceived(SdkPublicationReceivedHandler msReceived, int msType, string[][] mqArray, ref string errorMsg)
        {
            var eventType = SdkMsgType.UnDefineMsg;
            var otherMsg  = MsgConverter.ReceiveOtherMsgEntity(msType, mqArray, ref eventType, ref errorMsg);

            if (otherMsg == null)
            {
                return;
            }
            otherMsg.MsgType = eventType;
            msReceived?.Invoke(eventType, otherMsg);
        }
Beispiel #9
0
        public static void Run()
        {
            var url = "ws://localhost:53231";

            var webSocketsPool = ConnectionPool.Create("webSocketsPool",
                                                       openConnection: () =>
            {
                var ws = new ClientWebSocket();
                ws.ConnectAsync(new Uri(url), CancellationToken.None).Wait();
                return(ws);
            },
                                                       closeConnection: (connection) =>
            {
                connection.CloseAsync(WebSocketCloseStatus.NormalClosure, "", CancellationToken.None)
                .Wait();
            });
            //connectionsCount: 50);

            var pingStep = Step.Create("ping", async context =>
            {
                var msg = new WebSocketRequest
                {
                    CorrelationId = context.CorrelationId,
                    RequestType   = RequestType.Ping
                };
                var bytes = MsgConverter.ToJsonByteArray(msg);
                await context.Connection.SendAsync(bytes, WebSocketMessageType.Text, true, context.CancellationToken);
                return(Response.Ok());
            },
                                       pool: webSocketsPool);

            var pongStep = Step.Create("pong", async context =>
            {
                while (true)
                {
                    var(response, message) = await WebSocketsMiddleware.ReadFullMessage(context.Connection, context.CancellationToken);
                    var msg = MsgConverter.FromJsonByteArray <WebSocketResponse>(message);

                    if (msg.CorrelationId == context.CorrelationId)
                    {
                        return(Response.Ok(msg));
                    }
                }
            },
                                       pool: webSocketsPool);

            var scenario = ScenarioBuilder.CreateScenario("web_socket test", pingStep, pongStep);

            NBomberRunner.RegisterScenarios(scenario)
            .RunInConsole();
        }
        static void Main(string[] args)
        {
            const string filePath = "ImageTestDownload.msg";

            IMail msg;

            using (var converter = new MsgConverter(filePath))
            {
                msg = converter.CreateMessage();
            }

            Console.WriteLine(msg.Subject);
            Console.ReadLine();
        }
Beispiel #11
0
        public void readEmail()
        {
            using (MsgConverter converter = new MsgConverter(@"C:\Users\pramo_gsxqos1\Desktop\sample.msg"))
            {
                if (converter.Type == MsgType.Note)
                {
                    IMail email = converter.CreateMessage();

                    Console.WriteLine("Subject: {0}", email.Subject);
                    Console.WriteLine("Sender name: {0}", email.Sender.Name);
                    Console.WriteLine("Sender address: {0}", email.Sender.Address);

                    Console.WriteLine("Attachments: {0}", email.Attachments.Count);
                }
            }
        }
Beispiel #12
0
        public AgentCommand requestAgentCommand()
        {
            Dictionary <string, string> queryParams = new Dictionary <string, string>();

            queryParams.Add("client_ip", getLocalIPAddress());

            string urlPath = PcbAgent.buildUriForApiRequest(PcbAgent.REQUEST_AGENT_COMMAND);

            string result = HttpSender.requestNormal(urlPath, "GET", queryParams);

            Console.WriteLine("[requestAgentCommand] requestAgentCommand result:{0}", result);

            AgentCommand agentCmd = MsgConverter.unpack <AgentCommand>(result);

            return(agentCmd);
        }
Beispiel #13
0
        public string sendPcbGamePatchToMaster(PcbGamePatch pcbGamePatch)
        {
            if (pcbGamePatch == null)
            {
                return("pcbGamePatch is null!");
            }
            if (pcbGamePatch.pcbGames.Count == 0)
            {
                return("pcbGamePatch.pcbGames is empty!");
            }

            string urlPath = PcbAgent.buildUriForApiRequest(PcbAgent.REQUEST_GAME_PATCH + getLocalIPAddress());

            Console.WriteLine("[sendPcbGamePatchToMaster] pcbGamePatch result:{0}", MsgConverter.pack <PcbGamePatch>(pcbGamePatch));

            return(HttpSender.requestJson(urlPath, MsgConverter.pack <PcbGamePatch>(pcbGamePatch)));
        }
Beispiel #14
0
        public void readEmail()
        {
            using (MsgConverter converter = new MsgConverter(@"C:\Users\pramo_gsxqos1\Desktop\sample.msg"))
            {
                if (converter.Type == MsgType.Note)
                {
                    IMail email = converter.CreateMessage();

                    Console.WriteLine("Subject: {0}", email.Subject);
                    Console.WriteLine("Sender name: {0}", email.Sender.Name);
                    Console.WriteLine("Sender address: {0}", email.Sender.Address);
                    string Mailbody = email.GetBodyAsText();

                    getKeyPhrases(Mailbody);
                }
            }
        }
Beispiel #15
0
        public static Scenario BuildScenario()
        {
            var url = "ws://localhost:53231";

            var webSocketsPool = ConnectionPool.Create("webSocketsPool",
                                                       openConnection: () =>
            {
                var ws = new ClientWebSocket();
                ws.ConnectAsync(new Uri(url), CancellationToken.None).Wait();
                return(ws);
            },
                                                       closeConnection: (connection) =>
            {
                connection.CloseAsync(WebSocketCloseStatus.NormalClosure, "", CancellationToken.None)
                .Wait();
            });
            //connectionsCount: 50);

            var pingStep = Step.CreatePull("ping", webSocketsPool, async context =>
            {
                var msg = new WebSocketRequest
                {
                    CorrelationId = context.CorrelationId,
                    RequestType   = RequestType.Ping
                };
                var bytes = MsgConverter.ToJsonByteArray(msg);
                await context.Connection.SendAsync(bytes, WebSocketMessageType.Text, true, CancellationToken.None);
                return(Response.Ok());
            });

            var pongStep = Step.CreatePush("pong", webSocketsPool, async context =>
            {
                var(response, message) = await WebSocketsMiddleware.ReadFullMessage(context.Connection);
                var msg = MsgConverter.FromJsonByteArray <WebSocketResponse>(message);

                if (msg.CorrelationId == context.CorrelationId)
                {
                    context.UpdatesChannel.ReceivedUpdate(Response.Ok(msg));
                }
            });

            return(ScenarioBuilder.CreateScenario("web_socket test", pingStep, pongStep));
        }
Beispiel #16
0
        /// <summary>
        /// 方法说明:SDK发送聊天消息接口:文本、图片、音频、视频、文件、地理位置、图文混合、@消息、多人音频视频
        /// 完成时间:2017-05-16
        /// </summary>
        /// <param name="entity">发送消息实体</param>
        /// <param name="sendType">发送类型:正常聊天,重发聊天,机器人聊天</param>
        /// <param name="errorMsg">提示信息</param>
        /// <returns>是否成功发送消息</returns>
        public bool SdkPublishChatMsg <T>(T entity, ChatMsgSendType sendType, ref string errorMsg)
            where T : MsSdkMessageChat
        {
            var    jsonStr = MsgConverter.GetJsonByChatMsg <T>(entity, ref errorMsg);
            string topic;

            switch (sendType)
            {
            case ChatMsgSendType.Nomal:
            {
                topic = TopicSend.sdk_send.ToString();
            }
            break;

            case ChatMsgSendType.Repeat:
            {
                topic = TopicSend.sdk_resend.ToString();
            }
            break;

            case ChatMsgSendType.Robot:
            {
                topic = TopicSend.robot_send.ToString();
            }
            break;

            case ChatMsgSendType.Rerobot:
            {
                topic = TopicSend.robot_resend.ToString();
            }
            break;

            default:
            {
                topic = TopicSend.sdk_send.ToString();
            }
            break;
            }
            //发送消息
            return(!string.IsNullOrEmpty(jsonStr) && Publish(topic, jsonStr, false, ref errorMsg));
        }
        public static List <RecognitionDetails> Upload()
        {
            List <RecognitionDetails> _recognitionDetailsList = new List <RecognitionDetails>();

            string[] files = Directory.GetFiles(System.AppDomain.CurrentDomain.BaseDirectory + "uploads\\");
            for (int i = 0; i < files.Length; i++)
            {
                string fname = files[i];//System.AppDomain.CurrentDomain.BaseDirectory + "uploads\\" + filenames[0];
                using (MsgConverter converter = new MsgConverter(fname))
                {
                    if (converter.Type == MsgType.Note)
                    {
                        IMail email = converter.CreateMessage();
                        Console.WriteLine("Subject: {0}", email.Subject);
                        Console.WriteLine("Sender name: {0}", email.Sender.Name);
                        Console.WriteLine("Sender address: {0}", email.Sender.Address);
                        string Mailbody = email.GetBodyAsText();

                        string _keyphrases = getKeyPhrases(Mailbody);
                        string _cclist     = getCCList(email);
                        string _project    = GetProjectsList(Mailbody);

                        _recognitionDetailsList.Add(
                            new RecognitionDetails
                        {
                            Nominatedby = "Sunitha",
                            Project     = _project,
                            KeyPhrases  = _keyphrases,
                            Year        = "2020",
                            Content     = Mailbody,
                            TaggingList = _cclist
                        });
                    }
                }
            }
            return(_recognitionDetailsList);
        }
Beispiel #18
0
        /// <summary>
        /// 方法说明:SDK发送点对点阅后即焚消息已读回执
        /// 完成时间:2015-05-16
        /// </summary>
        /// <param name="receiptedchatmsgEntity">点对点聊天收到的阅后即焚消息实体</param>
        /// <param name="errorMsg">错误提示</param>
        /// <returns>是否成功发送点对点阅后即焚已读回执</returns>
        public bool SdkPublishPointBurnReadReceiptMsg(MsPointBurnReaded receiptedchatmsgEntity, ref string errorMsg)
        {
            var jsonStr = MsgConverter.GetJsonByPointReadedReceipt(receiptedchatmsgEntity, ref errorMsg);

            return(!string.IsNullOrEmpty(jsonStr) && Publish(TopicSend.sdk_send.ToString(), jsonStr, false, ref errorMsg));
        }
Beispiel #19
0
        /// <summary>
        /// 方法说明:SDK发送其他消息(结构是聊天消息的标准结构)
        /// 完成时间:2015-05-16
        /// </summary>
        /// <param name="otherMsg">发送的其他消息实体</param>
        /// <param name="errorMsg">错误提示</param>
        /// <returns>是否成功发其他标准消息</returns>
        public bool SdkPublishOtherMsg(MsSdkOther.SdkOtherBase otherMsg, ref string errorMsg)
        {
            var jsonStr = MsgConverter.GetJsonByOtherMsg(otherMsg, ref errorMsg);

            return(!string.IsNullOrEmpty(jsonStr) && Publish(TopicSend.sdk_send.ToString(), jsonStr, false, ref errorMsg));
        }
Beispiel #20
0
        /// <summary>
        /// 方法说明:注册方法接收离线消息
        /// </summary>
        /// <param name="mqofflineArray"></param>
        /// <returns></returns>
        private static void HandleOfflineReceived(SdkPublicationReceivedHandler msReceived, IReadOnlyCollection <string> mqofflineArray)
        {
            if (mqofflineArray == null || mqofflineArray.Count == 0)
            {
                return;
            }
            var contentobjList = new List <SdkMsBase>();

            foreach (var jsonContent in mqofflineArray)
            {
                var mqArray     = JsonConvert.DeserializeObject <string[][]>(jsonContent);
                var errorMsg    = string.Empty;
                var messageType = int.Parse(mqArray[0][0]);
                var eventType   = SdkMsgType.UnDefineMsg;
                //聊天信息接收:Text、Picture、Audio、File、MapLocation、MixImageText、At、MultiAudioVideo
                if (Enum.GetValues(typeof(SdkEnumCollection.ChatMsgType)).Cast <int>().ToList().Contains(messageType))
                {
                    var chatMsg = MsgConverter.ReceiveChatMsgEntity(messageType, mqArray, ref eventType, ref errorMsg);
                    if (chatMsg == null)
                    {
                        continue;
                    }
                    chatMsg.MsgType = eventType;
                    contentobjList.Add(chatMsg);
                }
                //用户信息接收:OffLine、OnLine、Leave、Busy、KickOut、Disable、ModifyInfo
                if (Enum.GetValues(typeof(SdkEnumCollection.UserStateNotify)).Cast <int>().ToList().Contains(messageType))
                {
                    var userMsg = MsgConverter.ReceiveUserMsgEntity(messageType, mqArray, ref eventType, ref errorMsg);
                    if (userMsg == null)
                    {
                        continue;
                    }
                    userMsg.MsgType = eventType;
                    contentobjList.Add(userMsg);
                }
                //聊天室信息接收:Create、Dismiss、AddMember、DeleteMember、QuitMember、ModifyMemberInfo、Modify
                if (Enum.GetValues(typeof(SdkEnumCollection.ChatRoomNotify)).Cast <int>().ToList().Contains(messageType))
                {
                    var roomMsg = MsgConverter.ReceiveRoomMsgEntity(messageType, mqArray, ref eventType, ref errorMsg);
                    if (roomMsg == null)
                    {
                        continue;
                    }
                    roomMsg.MsgType = eventType;
                    contentobjList.Add(roomMsg);
                }
                //讨论组(群)信息接收:Create、Dismiss、AddMember、DeleteMember、QuitMember、ModifyMemberInfo、Modify、BurnMode、NormalMode、BurnModeDelete
                if (Enum.GetValues(typeof(SdkEnumCollection.DiscussGroupInfoNotify))
                    .Cast <int>()
                    .ToList()
                    .Contains(messageType))
                {
                    var groupMsg = MsgConverter.ReceiveGroupMsgEntity(messageType, mqArray, ref eventType, ref errorMsg);
                    if (groupMsg == null)
                    {
                        continue;
                    }
                    groupMsg.MsgType = eventType;
                    contentobjList.Add(groupMsg);
                }
                //其他信息接收:[其他的信息]MsgReceipt、MultiTerminalSynch、PointFileAccepted、PointBurnReaded、VersionHardUpdate、OrganizationModify、UnvarnishedMsg
                //              [讨论组信息]UnReadNotifications、AddNotification、DeleteNotification、ModifyNotificationState
                if (Enum.GetValues(typeof(SdkEnumCollection.OtherMsgType)).Cast <int>().ToList().Contains(messageType) ||
                    Enum.GetValues(typeof(SdkEnumCollection.NotificationMsgType))
                    .Cast <int>()
                    .ToList()
                    .Contains(messageType))
                {
                    var otherMsg = MsgConverter.ReceiveOtherMsgEntity(messageType, mqArray, ref eventType, ref errorMsg);
                    if (otherMsg == null)
                    {
                        continue;
                    }
                    otherMsg.MsgType = eventType;
                    contentobjList.Add(otherMsg);
                }
                //后续确认合并处理
                if (messageType >= 4000 && messageType <= 9999)
                {
                    //自定义消息或透传消息
                    var otherMsg = MsgConverter.ReceiveOtherMsgEntity(messageType, mqArray, ref eventType, ref errorMsg);
                    if (otherMsg == null)
                    {
                        continue;
                    }
                    otherMsg.MsgType = eventType;
                    contentobjList.Add(otherMsg);
                }
            }
            if (contentobjList.Count == 0)
            {
                return;
            }
            msReceived?.Invoke(SdkMsgType.OffLineMessage, contentobjList);
        }
Beispiel #21
0
        private static void ReadAllEmails()
        {
            ProcessFile processFile = new ProcessFile();

            //Pattern 1
            foreach (string file in Directory.EnumerateFiles(@"C:\Users\g.griffo\Documents\Projects\Private\TripDashboard\emails\", "*Confirmado*.msg"))
            {
                using MsgConverter converter = new MsgConverter(file);
                if (converter.Type == MsgType.Note)
                {
                    IMail email = converter.CreateMessage();

                    string msgAsText = email.GetBodyAsText();

                    AddTrips(processFile.ProcessPortugueseFilePattern1(msgAsText));
                }
            }

            ////Pattern2
            foreach (string file in Directory.EnumerateFiles(@"C:\Users\g.griffo\Documents\Projects\Private\TripDashboard\emails\", "*Confirmação da reserva *.msg"))
            {
                using MsgConverter converter = new MsgConverter(file);
                if (converter.Type == MsgType.Note)
                {
                    IMail email = converter.CreateMessage();

                    string msgAsText = email.GetBodyAsText();

                    AddTrips(processFile.ProcessPortugueseFilePattern2(msgAsText, file));
                }
            }

            //Booking Confirmation
            foreach (string file in Directory.EnumerateFiles(@"C:\Users\g.griffo\Documents\Projects\Private\TripDashboard\emails\", "*Booking Confirmation*.msg"))
            {
                using MsgConverter converter = new MsgConverter(file);
                if (converter.Type == MsgType.Note)
                {
                    IMail email = converter.CreateMessage();

                    string msgAsText = email.GetBodyAsText();

                    AddTrips(processFile.ProcessEnglishFilePattern1(msgAsText, file));
                }
            }

            trips.Sort(delegate(Trip p1, Trip p2)
            {
                return(p1.Departure.CompareTo(p2.Departure));
            });

            //before your loop
            var csv = new StringBuilder();

            foreach (Trip trip in trips)
            {
                csv.AppendLine(trip.ToString());
            }
            //after your loop
            File.WriteAllText(@"C:\Users\g.griffo\Documents\Projects\Private\TripDashboard\Trips.csv", csv.ToString());
        }
Beispiel #22
0
        private static List <RecognitionDetails> BindRecognitionDetails()
        {
            List <RecognitionDetails> _lrecognitionDetails = new List <RecognitionDetails>();

            RecognitionDetails _recognitionDetails = new RecognitionDetails();

            _recognitionDetails.Content     = "Thank you for all your hard work and efforts on PHT. You are doing a great job and thank you";
            _recognitionDetails.Project     = "PHT";
            _recognitionDetails.KeyPhrases  = "hard work / great job";
            _recognitionDetails.Nominatedby = "Sunitha Rani";
            _recognitionDetails.TaggingList = "pramod";
            _recognitionDetails.Year        = "2019";
            _lrecognitionDetails.Add(_recognitionDetails);


            RecognitionDetails _recognitionDetails2 = new RecognitionDetails();

            _recognitionDetails2.Content     = "Mohit has gone above and beyond to provide the best client service possible. The client service we have provided as Deloitte would not be possible without his contribution. Your high quality delivery with in a short duration of time for GPD release has been Appreciated by the client.";
            _recognitionDetails2.Project     = "GDP";
            _recognitionDetails2.KeyPhrases  = "best client service possible / high quality delivery / short duration of time";
            _recognitionDetails2.Nominatedby = "Sunitha Rani";
            _recognitionDetails2.TaggingList = "[email protected]/[email protected]/[email protected]";
            _recognitionDetails2.Year        = "2020";
            _lrecognitionDetails.Add(_recognitionDetails2);

            RecognitionDetails _recognitionDetails3 = new RecognitionDetails();

            _recognitionDetails3.Content     = "Josh had a number of things that unfortunately hit all at once. He worked through everything in a professional manner. I want to recognize the quality and amount of work he did in that intense time. He not only led a DSTART scuccessfully but went above and beyond in his research, development of a pre-read, and virtual facilitation of a convening with national experts in immunization and race, she has stayed committed in a meaningful way, helping orient new teams to the topic and leading proposals. The impact of the work she produced had on the client positioned us for significant follow-on (e.g., from $95K in work to a new $1M+ contract).";
            _recognitionDetails3.Project     = "DSTART";
            _recognitionDetails3.KeyPhrases  = "professional manner / intense time / pre-read / virtual facilitation / national experts / meaningful way / orient new teams / significant follow-on / orient new teams ";
            _recognitionDetails3.Nominatedby = "Ganesh Subramainan";
            _recognitionDetails3.TaggingList = "[email protected]/[email protected]/[email protected]";
            _recognitionDetails3.Year        = "2020";
            _lrecognitionDetails.Add(_recognitionDetails3);


            RecognitionDetails _recognitionDetails4 = new RecognitionDetails();

            _recognitionDetails4.Content     = "Reward for outstanding service at a global S/4 HANA transformation, driving change and adoption for multiple workstreams in a highly-complex environment during a long-term assignment. also preventing escalation at FA when the client wasn't able to use templates to rationalize their item and vendor masters. David's hard work can be taken for granted as he quietly balances the client need with our teams capabilities. While our client should be taking ownership of our solution, it still falls to David to cover the areas they still have not taken on. In addition, David must work continuously with our team to help them achieve the quality that they are capable of.";
            _recognitionDetails4.Project     = "global S/4 HANA ";
            _recognitionDetails4.KeyPhrases  = "outstanding service / global S / multiple workstreams / complex environment / long-term assignment / David's hard work ";
            _recognitionDetails4.Nominatedby = "Sampath";
            _recognitionDetails4.TaggingList = "[email protected]/[email protected]/[email protected]";
            _recognitionDetails4.Year        = "2020";
            _lrecognitionDetails.Add(_recognitionDetails4);

            RecognitionDetails _recognitionDetails5 = new RecognitionDetails();

            _recognitionDetails5.Content     = "Wick has been delivering solid work on the engagement. More importantly, he is demonstrating her commitment to the success of this important contract on a daily basis and can always be relied upon. Wick’s work ethic is exemplary. He never balks at taking on challenging tasks or learning new skills. He routinely challenges himself to ratchet up his efficiencies and improve the quality of his work in TOD. Not only TOD he was successfully leading PHT also. The ownership he exhibits in consistently going above and beyond to bring in deliverables on or ahead of schedule is an inspiration to his team members. He is always willing to share his knowledge and collaborate with his team. ";
            _recognitionDetails5.Project     = "TOD / PHT";
            _recognitionDetails5.KeyPhrases  = "solid work / important contract / daily basis / new skills ";
            _recognitionDetails5.Nominatedby = "Sampath";
            _recognitionDetails5.TaggingList = "[email protected]/[email protected]/[email protected]";
            _recognitionDetails5.Year        = "2020";
            _lrecognitionDetails.Add(_recognitionDetails5);

            string[] files = Directory.GetFiles(System.AppDomain.CurrentDomain.BaseDirectory + "uploads\\");
            if (files.Length > 0)
            {
                for (int i = 0; i < files.Length; i++)
                {
                    string fname = files[i];//System.AppDomain.CurrentDomain.BaseDirectory + "uploads\\" + filenames[0];
                    using (MsgConverter converter = new MsgConverter(fname))
                    {
                        if (converter.Type == MsgType.Note)
                        {
                            IMail email = converter.CreateMessage();

                            Console.WriteLine("Subject: {0}", email.Subject);
                            Console.WriteLine("Sender name: {0}", email.Sender.Name);
                            Console.WriteLine("Sender address: {0}", email.Sender.Address);
                            string Mailbody = email.GetBodyAsText();

                            string _keyphrases = getKeyPhrases(Mailbody);
                            string _cclist     = getCCList(email);
                            string _project    = GetProjectsList(Mailbody);
                            _lrecognitionDetails.Add(
                                new RecognitionDetails
                            {
                                Nominatedby = "Sunitha",
                                Project     = _project,
                                KeyPhrases  = _keyphrases,
                                Year        = "2020",
                                Content     = Mailbody,
                                TaggingList = _cclist
                            });
                        }
                    }
                }
            }
            return(_lrecognitionDetails);
        }