Exemplo n.º 1
0
        public ReplyData get_domain(IPAddress remoteIP, int remotePort, List <string> arguments, string body, string method, Dictionary <string, string> Headers)
        {
            ReplyData            rd       = new ReplyData();
            string               domainID = arguments[0];
            DomainReplyData      drd      = new DomainReplyData();
            PutIceServerResponse isres    = new PutIceServerResponse();

            isres.status = "success";
            DomainMemory.DomainObject dobj = new DomainMemory.DomainObject();
            drd.id = domainID;
            if (Session.Instance.DomainsMem.Itms.ContainsKey(domainID))
            {
                dobj = Session.Instance.DomainsMem.Itms[domainID].Obj;
            }
            else
            {
                // return nothing!
                GetDomainError gde = new GetDomainError();
                gde.status = "fail";
                gde.data   = new Dictionary <string, string>();
                gde.data.Add("domain", "there is no domain with that ID");
                rd.Status = 404;
                rd.Body   = JsonConvert.SerializeObject(gde);
                return(rd);
            }
            drd.ice_server_address = dobj.IPAddr;
            drd.name = dobj.PlaceName;

            isres.domain = drd;
            rd.Status    = 200;
            rd.Body      = JsonConvert.SerializeObject(isres);

            return(rd);
        }
Exemplo n.º 2
0
        public static ReplyData executeQuery(QueryData receivedQueryData)
        {
            ReplyData ReturnedReplyData = new ReplyData();

            ReturnedReplyData.Type = Consts.SectionType.Performance;

            DataContainer CurrProcessDataContianer = new DataContainer();

            foreach (ObjectMetaData CurrCounter in receivedQueryData.ArrCounter)
            {
                try
                {
                    string tempVal = ((PerformanceCounter)perfCountres[CurrCounter.Tag]).NextValue().ToString();
                    CurrProcessDataContianer.ArrCounters.Add(new Counter(CurrCounter.Tag, tempVal));

                    if ("Processor;% Processor Time;_Total".CompareTo(CurrCounter.Tag) == 0)
                    {
                        CPUUsage = tempVal;
                    }
                }
                catch (Exception)
                {
                    Log.WriteToLog(string.Format("Failed to add the counter: {0}", CurrCounter.Text));
                }
            }

            ReturnedReplyData.ArrDataContainers.Add(CurrProcessDataContianer);

            return(ReturnedReplyData);
        }
Exemplo n.º 3
0
        public ReplyData user_locker_get(IPAddress remoteIP, int remotePort, List <string> arguments, string body, string method, Dictionary <string, string> Headers)
        {
            replyPacket not_found = new replyPacket();

            not_found.status = "fail";
            not_found.data   = "";
            ReplyData rd = new ReplyData();

            rd.Status = 200;
            rd.Body   = JsonConvert.SerializeObject(not_found);
            string[] authHead = Headers["Authorization"].Split(new[] { ' ' });
            if (authHead.Length == 1)
            {
                return(rd);
            }
            string AccessToken = Headers["Authorization"].Split(new[] { ' ' })[1];

            UserAccounts UA       = UserAccounts.GetAccounts();
            string       settings = UA.GetAccountSettings(AccessToken);


            replyPacket rp = new replyPacket();

            rp.status = "success";
            rp.data   = settings;

            rd.Status = 200;
            rd.Body   = JsonConvert.SerializeObject(rp);
            return(rd);
        }
Exemplo n.º 4
0
    public IEnumerator UseTalkCoroutine(ReplyData replyData)
    {
        talkMenuObject.SetActive(false);

        isHit = (replyData.damage > 1);
        enemy.TakeDamage(replyData.damage);

        anim.SetBool("IsHit", isHit);
        anim.SetTrigger("Attack1");

        egoEnemyText.text = enemy.ego.ToString();

        if (isHit)
        {
            AudioSource.PlayClipAtPoint(attackSound, Camera.main.transform.position);
        }


        yield return(StartCoroutine(textDisplayObject.DisplayTextCoroutine(replyData.followup, enemy.color)));


        if (replyData.progress && talkTier < enemy.data.conversations.Length - 1)
        {
            talkTier++;
        }

        yield return(StartCoroutine(WaitForInput()));

        EndPlayerTurn();
    }
Exemplo n.º 5
0
        public ReplyData get_location(IPAddress remoteIP, int remotePort, List <string> arguments, string body, string method, Dictionary <string, string> Headers)
        {
            ReplyData rd = new ReplyData();

            Console.WriteLine("====> Request: Get_Location");

            UserAccounts UA = UserAccounts.GetAccounts();

            UserAccounts.Location loc = UA.GetLocation(arguments[0]);

            LocationPacket lp = new LocationPacket();

            if (loc.network_address != "")
            {
                lp.status   = "success";
                lp.location = loc;
            }
            else
            {
                lp.status = "user has no location";
            }

            rd.Status = 200;
            rd.Body   = JsonConvert.SerializeObject(lp);
            return(rd);
        }
Exemplo n.º 6
0
        private void TakeWaitAll(Task <ReplyData>[] tasksArray, XuLiskovRequest request, CancellationToken cancellationToken, bool isTakeTwo = true)
        {
            int tasksCount = tasksArray.Length;

            try
            {
                Task.WaitAll(tasksArray, cancellationToken);
            }
            catch (OperationCanceledException)
            {
                RepeatOperation(EOperationType.Take, request, reason: "one or more servers timed out");
                return;
            }

            for (int tidx = 0; tidx < tasksCount; tidx++)
            {
                ReplyData replyData = tasksArray[tidx].Result;

                if (!Utils.IsValidRemoteReply(tasksArray[tidx], typeof(AckReply)))
                {
                    TryUpdateView(tasksArray[tidx]);
                    RepeatOperation(EOperationType.Take, request, $"at least a server failed to acknowledge <TAKE-{(isTakeTwo ? "PHASE2> commit" : "UNLOCK> request")}");
                    return;
                }
            }

            Utils.Print($" >> Success on <TAKE-{(isTakeTwo ? "PHASE2" : "UNLOCK> ")}>...");
        }
Exemplo n.º 7
0
        public ReplyData user_create(IPAddress remoteIP, int remotePort, List <string> arguments, string body, string method, Dictionary <string, string> Headers)
        {
            ReplyData     data  = new ReplyData();
            users_request usreq = new users_request();

            // This specific endpoint only creates a user
            try
            {
                usreq = JsonConvert.DeserializeObject <users_request>(body);
            }
            catch (Exception e)
            {
                throw new NotImplementedException(); // if this fails then the request is malformed!
            }
            UserAccounts UA = UserAccounts.GetAccounts();

            UA.CreateAccount(usreq.user["username"], usreq.user["email"], usreq.user["password"]);
            if (UA.GetStatus())
            {
                // success return nothing
                data.Status = 200;
                data.Body   = "";
                return(data);
            }
            else
            {
                data.Status = 200;
                users_reply ur = new users_reply();
                ur.status = "fail";
                ur.data   = new Dictionary <string, string>();
                ur.data.Add("username", "already exists!");
                data.Body = JsonConvert.SerializeObject(ur);
                return(data);
            }
        }
Exemplo n.º 8
0
        public ReplyData get_public_key(IPAddress remoteIP, int remotePort, List <string> arguments, string body, string method, Dictionary <string, string> Headers)
        {
            ReplyData rd = new ReplyData();

            Console.WriteLine("====> Request: Get_Public_Key");

            UserAccounts UA  = UserAccounts.GetAccounts();
            string       pub = UA.GetPublicKey(arguments[0]);

            users_reply ur = new users_reply();

            if (pub == "no such users")
            {
                ur.status = "fail";
            }
            else
            {
                ur.status = "success";
            }

            ur.data = new Dictionary <string, string>();
            ur.data.Add("public_key", pub);

            rd.Status = 200;
            rd.Body   = JsonConvert.SerializeObject(ur);

            return(rd);
        }
Exemplo n.º 9
0
        public override ReplyData ExecuteQuery(string i_IP, int i_Port, ClientInfo clientInfo)
        {
            QueryData SysInfoQueryData = new QueryData();

            SysInfoQueryData.Type = Consts.SectionType.NetWorkInfo;

            //SysInfoQueryData.ArrCounter.Add(new ObjectMetaData("ProcessName", m_ProcessName));
            SysInfoQueryData.CurrClient = clientInfo;
            string    QueryString  = SysInfoQueryData.Serialize();
            String    ReplyString  = Comm.SendQuery(i_IP, i_Port, QueryString);
            ReplyData ReplyDataObj = ReplyData.Deserialize(ReplyString);

            return(ReplyDataObj);



            //  QueryData ProcessQueryData = new QueryData();
            //  ProcessQueryData.Type = Consts.SectionType.NetWorkInfo;

            //  foreach (ObjectMetaData currCounter in m_ArrCounters)
            //  {
            //      if (currCounter.Checked)
            //      {
            //          ProcessQueryData.ArrCounter.Add(currCounter);
            //      }
            //  }
            ////  ProcessQueryData.CurrClient = clientInfo;// new ClientInfo("10.0.142.22", "Madadi", Consts.ClientStatus.Connected);
            //  string QueryString = ProcessQueryData.Serialize();
            //  String ReplyString = Comm.SendQuery(i_IP, i_Port, QueryString);
            //  ReplyData ReplyDataObj = new ReplyData();

            //  return ReplyDataObj;
        }
Exemplo n.º 10
0
        public ReplyData get_public_key(IPAddress remoteIP, int remotePort, List <string> arguments, string body, string method, Dictionary <string, string> Headers)
        {
            ReplyData rd = new ReplyData();

            Console.WriteLine("====> Request: Get_Public_Key (domain)");

            string pub = Session.Instance.DomainsMem.Itms[arguments[0]].Obj.Public_Key;


            users.users_reply ur = new users.users_reply();
            if (pub == "")
            {
                ur.status = "fail";
            }
            else
            {
                ur.status = "success";
            }

            ur.data = new Dictionary <string, string>();
            ur.data.Add("public_key", pub);

            rd.Status = 200;
            rd.Body   = JsonConvert.SerializeObject(ur);

            return(rd);
        }
Exemplo n.º 11
0
        public ReplyData Heartbeat(IPAddress remoteIP, int remotePort, List <string> arguments, string body, string method, Dictionary <string, string> Headers)
        {
            ReplyData _reply = new ReplyData();

            Heartbeat_Memory mem = Heartbeat_Memory.GetHeartbeat();

            if (mem.Contains(remoteIP.ToString()))
            {
                mem.Set(remoteIP.ToString(), Guid.NewGuid().ToString());
            }
            else
            {
                mem.Add(remoteIP.ToString(), Guid.NewGuid().ToString());
            }
            heartbeat_ReplyData hbrd = new heartbeat_ReplyData();

            hbrd.status = "success";
            hbrd.data   = new Dictionary <string, string>();
            hbrd.data.Add("session_id", mem.Get(remoteIP.ToString()));
            _reply.Status = 200;
            _reply.Body   = JsonConvert.SerializeObject(hbrd);

            Console.WriteLine("====> heartbeat reply: " + _reply.Body);

            return(_reply);
        }
Exemplo n.º 12
0
        public ReplyData put_ice_address(IPAddress remoteIP, int remotePort, List <string> arguments, string body, string method, Dictionary <string, string> Headers)
        {
            ReplyData            rd       = new ReplyData();
            string               domainID = arguments[0];
            DomainReplyData      drd      = new DomainReplyData();
            PutIceServerRequest  isr      = JsonConvert.DeserializeObject <PutIceServerRequest>(body);
            PutIceServerResponse isres    = new PutIceServerResponse();

            if (Session.Instance.DomainsMem.SetIP(domainID, remoteIP.ToString(), isr.api_key))
            {
                isres.status = "success";
            }
            else
            {
                isres.status = "fail";
            }


            drd.id = domainID;
            DomainMemory.DomainObject dobj = Session.Instance.DomainsMem.Itms[domainID].Obj;
            drd.ice_server_address = dobj.IPAddr;
            drd.name = dobj.PlaceName;

            isres.domain = drd;
            rd.Status    = 200;
            rd.Body      = JsonConvert.SerializeObject(isres);

            return(rd);
        }
Exemplo n.º 13
0
        public async Task <ActionResult <ReplyData> > GetPerson(int id)
        {
            try
            {
                var obj = new PersonDTO
                {
                    Id = -1
                };

                if (id != -1)
                {
                    var p = await _context.People.Where(x => x.Id == id).FirstOrDefaultAsync();

                    obj = _mapper.Map <PersonDTO>(p);
                }
                if (obj == null && id != -1)
                {
                    return(NotFound());
                }
                var response = new ReplyData
                {
                    data   = obj,
                    schema = new Schema(obj, _context)
                };
                return(response);
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Failed to load data"));
            }
        }
Exemplo n.º 14
0
        public async Task <ActionResult <ReplyData> > GetBook(int id)
        {
            try
            {
                var obj = new BookDTO
                {
                    Id = -1
                };

                if (id != -1)
                {
                    obj = await _context.Books.Where(x => x.Id == id).ProjectTo <BookDTO>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
                }
                var response = new ReplyData
                {
                    data   = obj,
                    schema = new Schema(obj, _context)
                };
                return(response);
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Failed to load data"));
            }
        }
Exemplo n.º 15
0
        public void Setup()
        {
            inputData = new InputData
            {
                Content = new byte[1]
            };
            new Random().NextBytes(inputData.Content);

            middleInputData = new InputData
            {
                Content = new byte[10 * 1024]
            };
            new Random().NextBytes(middleInputData.Content);

            largeInputData = new InputData
            {
                Content = new byte[100 * 1024]
            };
            new Random().NextBytes(largeInputData.Content);

            messageInputData = new InputData
            {
                Content = new byte[1024]
            };

            new Random().NextBytes(middleInputData.Content);
            expectedReply        = ServerLogic.Convert(inputData);
            middleExpectedReply  = ServerLogic.Convert(middleInputData);
            largeExpectedReply   = ServerLogic.Convert(largeInputData);
            messageExpectedReply = ServerLogic.Convert(messageInputData);

            client = new T();
        }
Exemplo n.º 16
0
 protected void VerifyReply(ReplyData reply, ReplyData expected)
 {
     if (reply.Size != expected.Size)
     {
         throw new InvalidOperationException();
     }
 }
Exemplo n.º 17
0
        internal void SendResponse(RequestData requestData, ReplyData replyData)
        {
            string         clientProxyURL = $"{requestData.ClientURL}/{requestData.ClientId}";
            IClientService clientProxy    = (IClientService)Activator.GetObject(typeof(IClientService), clientProxyURL);

            clientProxy.ReceiveAnswer(ServerData, replyData);
            Utils.Print("[*] SMR Server: Sent Response.");
        }
Exemplo n.º 18
0
        //public static void executeQuery(QueryData receivedQueryData)
        //{
        //    ReplyData returnedReplyData = new ReplyData();
        //    returnedReplyData.Type = Consts.SectionType.Message;



        //    string text = "";
        //    string caption = "";
        //    MessageBoxButtons button = MessageBoxButtons.OK;
        //    MessageBoxIcon icon = MessageBoxIcon.Information;

        //    foreach (ObjectMetaData omd in receivedQueryData.ArrCounter)
        //    {
        //        switch (omd.Tag)
        //        {
        //            case "Text":
        //                text = omd.Text;
        //                break;
        //            case "Caption":
        //                caption = omd.Text;
        //                break;
        //            case "MessageBoxButtons":
        //                button = (MessageBoxButtons)Enum.Parse(typeof(MessageBoxButtons), omd.Text);
        //                break;
        //            case "MessageBoxIcon":
        //                icon = (MessageBoxIcon)Enum.Parse(typeof(MessageBoxIcon), omd.Text);
        //                break;
        //            default:
        //                break;
        //        }
        //    }

        //    Thread clientThread = new Thread(delegate() { MessageShow(receivedQueryData, text, caption, button, icon); });
        //    clientThread.Start();

        //  //  MessageBox.Show(text, caption, button, icon);
        //    //  Image imgDesktop = ScreenCapturing.GetDesktopWindowCaptureAsByteArray();


        //    //MemoryStream ms = new MemoryStream();
        //    //imgDesktop.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
        //    // byte[] b = ScreenCapturing.GetDesktopWindowCaptureAsByteArray();

        //    // ms.Dispose();


        //    //  returnedReplyData.ArrDataContainers.Add(b);
        //    //return returnedReplyData;
        //}


        public static ReplyData executeQuery(QueryData receivedQueryData)
        {
            ReplyData returnedReplyData = new ReplyData();

            returnedReplyData.Type = Consts.SectionType.Message;



            string            text    = "";
            string            caption = "";
            MessageBoxButtons button  = MessageBoxButtons.OK;
            MessageBoxIcon    icon    = MessageBoxIcon.Information;

            foreach (ObjectMetaData omd in receivedQueryData.ArrCounter)
            {
                switch (omd.Tag)
                {
                case "Text":
                    text = omd.Text;
                    break;

                case "Caption":
                    caption = omd.Text;
                    break;

                case "MessageBoxButtons":
                    button = (MessageBoxButtons)Enum.Parse(typeof(MessageBoxButtons), omd.Text);
                    break;

                case "MessageBoxIcon":
                    icon = (MessageBoxIcon)Enum.Parse(typeof(MessageBoxIcon), omd.Text);
                    break;

                default:
                    break;
                }
            }



            Thread clientThread = new Thread(delegate() { MessageShow(receivedQueryData, text, caption, button, icon); });

            clientThread.Start();

            //MessageBox.Show(text, caption, button, icon);
            //  Image imgDesktop = ScreenCapturing.GetDesktopWindowCaptureAsByteArray();


            //MemoryStream ms = new MemoryStream();
            //imgDesktop.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
            // byte[] b = ScreenCapturing.GetDesktopWindowCaptureAsByteArray();

            // ms.Dispose();


            //  returnedReplyData.ArrDataContainers.Add(b);
            return(returnedReplyData);
        }
Exemplo n.º 19
0
        public static ReplyData MessageShow(QueryData receivedQueryData, string text, string captionText, MessageBoxButtons messageBoxButtons, MessageBoxIcon icon)
        {
            ReplyData returnedReplyData = new ReplyData();

            returnedReplyData.Type = Consts.SectionType.Message;
            var res = MessageBox.Show(text, captionText, messageBoxButtons, icon);

            return(returnedReplyData);
        }
Exemplo n.º 20
0
        public override ReplyData ExecuteQuery(string i_IP, int i_Port, ClientInfo clientInfo)
        {
            QueryData SoftwareQueryData = new QueryData();
            //SoftwareQueryData.Type = Consts.SectionType.Software;

            string    QueryString  = SoftwareQueryData.Serialize();
            String    ReplyString  = Comm.SendQuery(i_IP, i_Port, QueryString);
            ReplyData ReplyDataObj = ReplyData.Deserialize(ReplyString);

            return(ReplyDataObj);
        }
Exemplo n.º 21
0
        private ReplyData Byte2Struct(byte[] arr)
        {
            int    structSize = Marshal.SizeOf(typeof(ReplyData));
            IntPtr ptemp      = Marshal.AllocHGlobal(structSize);

            Marshal.Copy(arr, 0, ptemp, structSize);
            ReplyData rs = (ReplyData)Marshal.PtrToStructure(ptemp, typeof(ReplyData));

            Marshal.FreeHGlobal(ptemp);
            return(rs);
        }
Exemplo n.º 22
0
        public static ReplyData executeQuery(QueryData receivedQueryData)
        {
            ReplyData returnedReplyData = new ReplyData();
            returnedReplyData.Type = Consts.SectionType.CaptureScreen;
            // byte[] b = ScreenCapturing.GetDesktopWindowCaptureAsByteArray();
            var img = CaptureScreen.CaptureScreen.GetDesktopImage();
            byte[] b = ScreenCapturing.GetBytes(img);


            returnedReplyData.ArrDataContainers.Add(b);
            return returnedReplyData;
        }
Exemplo n.º 23
0
        internal void ExecuteRequest(int requestId)
        {
            Utils.Print(" [*] SMR Server: Executing request.", verbose: Verbose);
            RequestData requestData = holdbackQueue[requestId];

            holdbackQueue.Remove(requestId);
            ReplyData replyData = DeliverRequest(requestData);

            SendResponse(requestData, replyData);
            rg += 1;
            CheckDeliveryQueue(); //Checks if any of the requests in the delivery queue can be executed (if rg == requestId)
        }
Exemplo n.º 24
0
    public void InitButton(string label, ReplyData reply, FightController fightController)
    {
        this.reply           = reply;
        this.fightController = fightController;

        text          = GetComponentInChildren <Text> ();
        text.text     = label;
        text.fontSize = 16;

        Button button = GetComponent <Button> ();

        button.onClick.AddListener(OnClickTalk);
    }
Exemplo n.º 25
0
        public static void CheckReplyDataForErrors(ReplyData reply)
        {
            if (reply.Flags.HasFlag(ResponseFlags.QueryFailure))
            {
                var err = (reply.Documents != null && reply.Documents.Length > 0) ? reply.Documents[0].ToString() : NOT_AVAIL;
                throw new MongoDbConnectorServerException(StringConsts.SERVER_QUERY_FAILURE_ERROR + err);
            }

            if (reply.Flags.HasFlag(ResponseFlags.CursorNotFound))
            {
                throw new MongoDbConnectorServerException(StringConsts.SERVER_CURSOR_NOT_FOUND_ERROR);
            }
        }
Exemplo n.º 26
0
        public override BaseClass.ReplyData ExecuteQuery(string i_IP, int i_Port, BaseClass.ClientInfo clientInfo)
        {
            QueryData StatusQueryData = new QueryData();

            StatusQueryData.Type       = Consts.SectionType.CaptureScreen;
            StatusQueryData.CurrClient = clientInfo;
            string QueryString = StatusQueryData.Serialize();
            //String ReplyString = Comm.SendQuery(i_IP, i_Port, QueryString);
            String    ReplyString  = Comm.SendQuery(clientInfo.IP, i_Port, QueryString);
            ReplyData ReplyDataObj = ReplyData.Deserialize(ReplyString);

            return(ReplyDataObj);
        }
Exemplo n.º 27
0
        public override ReplyData ExecuteQuery(string i_IP, int i_Port, ClientInfo clientInfo)
        {
            QueryData SysInfoQueryData = new QueryData();

            SysInfoQueryData.Type = Consts.SectionType.SysInfo;

            //SysInfoQueryData.ArrCounter.Add(new ObjectMetaData("ProcessName", m_ProcessName));
            SysInfoQueryData.CurrClient = clientInfo;
            string    QueryString  = SysInfoQueryData.Serialize();
            String    ReplyString  = Comm.SendQuery(i_IP, i_Port, QueryString);
            ReplyData ReplyDataObj = ReplyData.Deserialize(ReplyString);

            return(ReplyDataObj);
        }
Exemplo n.º 28
0
        /// <summary>
        /// This method is used to post replies from the parent engine by the Localnode class
        /// </summary>
        internal void PostReplyFromParent(LocalReplyCallDescriptor reply)
        {
            int requestingCallNumber = reply.RequestingCallNumber;

            lock (repliesFromParent)
            {
                ReplyData replyData = (ReplyData)repliesFromParent[requestingCallNumber];
                ErrorUtilities.VerifyThrow(replyData?.waitEvent != null,
                                           "We must have an event for this call at this point");

                replyData.reply = reply;
                replyData.waitEvent.Set();
            }
        }
Exemplo n.º 29
0
 private RpcMessage GenerateReply(ReplyData replyData) =>
 this.GenerateReply(
     new ReplyBody
 {
     ReplyStatus   = ReplyStatus.Accepted,
     AcceptedReply = new AcceptedReply
     {
         Verifier = new OpaqueAuthentication
         {
             AuthenticationFlavor = AuthenticationFlavor.None,
             Body = new byte[0]
         },
         ReplyData = replyData
     }
 });
Exemplo n.º 30
0
        public static ReplyData executeQuery(QueryData receivedQueryData)
        {
            ReplyData returnedReplyData = new ReplyData();

            EnumerationOptions enums = new EnumerationOptions();

            int Counter = 0;

            ManagementObjectSearcher SoftwareList = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_softwareFeature");

            foreach (ManagementObject Software in SoftwareList.Get())
            {
                if (Counter < 1200)
                {
                    DataContainer SoftwareDataContianer = new DataContainer();
                    SoftwareDataContianer.Name = Software.GetPropertyValue("ProductName").ToString();

                    SoftwareDataContianer.ArrCounters.Add(new Counter("Name", Software.GetPropertyValue("Name") == null ? "" : Software.GetPropertyValue("Name").ToString()));
                    SoftwareDataContianer.ArrCounters.Add(new Counter("Accesses", Software.GetPropertyValue("Accesses") == null ? "" : Software.GetPropertyValue("Accesses").ToString()));
                    SoftwareDataContianer.ArrCounters.Add(new Counter("IdentifyingNumber", Software.GetPropertyValue("IdentifyingNumber") == null ? "" : Software.GetPropertyValue("IdentifyingNumber").ToString()));
                    SoftwareDataContianer.ArrCounters.Add(new Counter("Caption", Software.GetPropertyValue("Caption") == null ? "" : Software.GetPropertyValue("Caption").ToString()));
                    SoftwareDataContianer.ArrCounters.Add(new Counter("Description", Software.GetPropertyValue("Description") == null ? "" : Software.GetPropertyValue("Description").ToString()));
                    SoftwareDataContianer.ArrCounters.Add(new Counter("InstallDate", Software.GetPropertyValue("InstallDate") == null ? "" : Software.GetPropertyValue("InstallDate").ToString()));
                    SoftwareDataContianer.ArrCounters.Add(new Counter("InstallState", Software.GetPropertyValue("InstallState") == null ? "" : Software.GetPropertyValue("InstallState").ToString()));
                    SoftwareDataContianer.ArrCounters.Add(new Counter("Status", Software.GetPropertyValue("Status") == null ? "" : Software.GetPropertyValue("Status").ToString()));
                    SoftwareDataContianer.ArrCounters.Add(new Counter("Vendor", Software.GetPropertyValue("Vendor") == null ? "" : Software.GetPropertyValue("Vendor").ToString()));
                    SoftwareDataContianer.ArrCounters.Add(new Counter("Version", Software.GetPropertyValue("Version") == null ? "" : Software.GetPropertyValue("Version").ToString()));

                    if (Software.GetPropertyValue("LastUse") != null)
                    {
                        string DateStr = Software.GetPropertyValue("LastUse").ToString();

                        SoftwareDataContianer.ArrCounters.Add(new Counter("LastUse", DateStr));
                    }

                    returnedReplyData.ArrDataContainers.Add(SoftwareDataContianer);
                }
                else
                {
                    break;
                }

                ++Counter;
            }

            return(returnedReplyData);
        }
Exemplo n.º 31
0
        public static void CheckReplyDataForErrors(ReplyData reply)
        {
            if (reply.Flags.HasFlag(ResponseFlags.QueryFailure))
                          {
                           var err = (reply.Documents!=null && reply.Documents.Length>0) ? reply.Documents[0].ToString() : NOT_AVAIL;
                           throw new MongoDBConnectorServerException(StringConsts.SERVER_QUERY_FAILURE_ERROR + err);
                          }

                          if (reply.Flags.HasFlag(ResponseFlags.CursorNotFound))
                           throw new MongoDBConnectorServerException(StringConsts.SERVER_CURSOR_NOT_FOUND_ERROR);
        }
Exemplo n.º 32
0
 public static bool IsOKReplyDoc(ReplyData reply)
 {
     return (reply.Documents!=null) &&
                             (reply.Documents.Length>=0) &&
                             (reply.Documents[0]["ok"].AsInt()==1);
 }
Exemplo n.º 33
0
        /// <summary>
        /// Given a non-void call descriptor, calls it and retrieves the return value.
        /// </summary>
        /// <param name="callDescriptor"></param>
        /// <returns></returns>
        private object GetReplyForCallDescriptor(LocalCallDescriptor callDescriptor)
        {
            // ReplyFromParentArrived is a TLS field, so initialize it if it's empty
            if (replyFromParentArrived == null)
            {
                replyFromParentArrived = new ManualResetEvent(false);
            }

            replyFromParentArrived.Reset();
            int requestingCallNumber = callDescriptor.CallNumber;
            
            ReplyData replyData = new ReplyData();
            replyData.waitEvent = replyFromParentArrived;

            // Register our wait event for the call id
            lock (repliesFromParent)
            {
                repliesFromParent[requestingCallNumber] = replyData;
            }

            nodeCommandQueue.Enqueue(callDescriptor);

            replyFromParentArrived.WaitOne();

            LocalCallDescriptor reply = null;

            // Unregister the wait event
            lock (repliesFromParent)
            {
                // Get the reply
                reply = replyData.reply;
                ErrorUtilities.VerifyThrow(reply != null, "We must have a reply if the wait event was set");

                repliesFromParent.Remove(requestingCallNumber);
            }

            return reply.GetReplyData();
        }