Exemplo n.º 1
0
        public static long?SendContentedNuntias(Nuntias newNuntias)
        {
            JObject nuntiasJsonData = newNuntias.ToJson();

            nuntiasJsonData["sender_mac_address"] = Universal.SystemMACAddress;
            long?  nuntiasId = null;
            string filePath  = LocalDataFileAccess.GetFilePathInLocalData(newNuntias.ContentFileId);

            if (filePath == null)
            {
                return(null);
            }
            byte[] fileByte = Universal.FileToByteArray(filePath);
            KeyValuePair <JObject, byte[]> nuntiasData = new KeyValuePair <JObject, byte[]>(nuntiasJsonData, fileByte);

            ServerHub.WorkingInstance.ServerHubProxy.Invoke <long>("SendContentedNuntias", nuntiasData).ContinueWith(task =>
            {
                if (!task.IsFaulted)
                {
                    nuntiasId = task.Result;
                }
                else
                {
                    Console.WriteLine(task.IsFaulted);
                }
            }).Wait();
            return(nuntiasId);
        }