public async Task <dynamic> ExecuteTargetOperation(ActiveOperation ops, List <IDictionary <string, object> > sfObject)
        {
            dynamic result = null;

            ForceClient client           = new ForceClient(await GetClientOptions());
            var         intermediateJson = JsonConvert.DeserializeObject <string>(ops.Content);

            try
            {
                foreach (var obj in sfObject)
                {
                    var id = obj.Where(s => s.Key == "Id").Select(s => s.Value).FirstOrDefault().ToString();
                    obj.Remove("Id");

                    await client.UpdateRecord(intermediateJson, id, obj, null);
                    await LogInfo("Salesforce Updated Succesfully");
                }
            }
            catch (System.Exception ex)
            {
                await LogError("Salesforce Updatation Failed", ex.Message);

                throw ex;
            }

            return(result);
        }
Example #2
0
        ProcessAddOOBElement(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Ops.AddOOBUnit add
                = p as ANWI.Messaging.Ops.AddOOBUnit;

            ActiveOperation op = GetOperation(add.opUUID);

            if (op != null)
            {
                if (add.type == ANWI.Messaging.Ops.AddOOBUnit.Type.FleetShip)
                {
                    op.AddFleetShip(add.shipId);
                }
                else if (add.type == ANWI.Messaging.Ops.AddOOBUnit.Type.Wing)
                {
                    op.AddWing();
                }
                else if (add.type == ANWI.Messaging.Ops.AddOOBUnit.Type.Boat)
                {
                    op.AddBoat(add.wingUUID, add.hullId);
                }
            }

            return(null);
        }
        internal async Task PlayAdAsync(IAdSource adSource, TimeSpan?startTimeout, CancellationToken cancellationToken, IProgress <AdStatus> progress)
#endif
        {
            if (!(adSource.Payload is AdDocumentPayload))
            {
                throw new ArgumentException("adSource must contain a payload of type AdDocumentPayload", "adPayload");
            }
            var adDoc = (AdDocumentPayload)adSource.Payload;

            // do an extra check to catch an empty payload before we get any further.
            if (adDoc.AdPods.Count == 0)
            {
                VpaidController.TrackErrorUrl(adDoc.Error, Microsoft.Media.Advertising.VpaidController.Error_NoAd);
                var playExection = new PlayException(new LoadException(new Exception("No ads found.")));
                LogError(adSource, playExection);
                throw playExection;
            }

            // create a new token that we can cancel independently
            var masterCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
            var playTasks = PlayAdAsync(adDoc, adSource, startTimeout, masterCancellationToken.Token, progress);

            try
            {
                activeOperation = new ActiveOperation(playTasks.Secondary, masterCancellationToken);
                await playTasks.Primary;
            }
            catch (PlayException)
            {
                activeOperation = null;
                throw;
            }
        }
Example #4
0
        ProcessAddPosition(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Ops.AddPosition add
                = p as ANWI.Messaging.Ops.AddPosition;

            ActiveOperation op = GetOperation(add.opUUID);

            if (op != null)
            {
                op.AddPosition(add.unitUUID, add.roleID);
            }

            return(null);
        }
Example #5
0
        /// <summary>
        /// Removes the user from all operations in the event of a crash or
        /// connection loss.
        /// </summary>
        private void UnsubAllOperations()
        {
            logger.Error($"{GetLogIdentifier()} lost connection.  Removing them"
                         + $" from {subscribedOps.Count} operations.");

            foreach (string uuid in subscribedOps)
            {
                ActiveOperation op = GetOperation(uuid);
                if (op != null)
                {
                    op.UnsubscribeUser(GetTokenCookie());
                }
            }
        }
Example #6
0
        ProcessSetFreeMove(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Ops.SetFreeMove sfm
                = p as ANWI.Messaging.Ops.SetFreeMove;

            ActiveOperation op = GetOperation(sfm.opUUID);

            if (op != null)
            {
                op.SetFreeMove(sfm.freeMove);
            }

            return(null);
        }
Example #7
0
        ProcessSetC2Type(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Ops.SetC2Type sc2
                = p as ANWI.Messaging.Ops.SetC2Type;

            ActiveOperation op = GetOperation(sc2.opUUID);

            if (op != null)
            {
                op.SetC2Type(sc2.unified);
            }

            return(null);
        }
Example #8
0
        ProcessSetPositionCritical(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Ops.SetPositionCritical set
                = p as ANWI.Messaging.Ops.SetPositionCritical;

            ActiveOperation op = GetOperation(set.opUUID);

            if (op != null)
            {
                op.SetPositionCritical(set.posUUID, set.critical);
            }

            return(null);
        }
Example #9
0
        ProcessModifyUnit(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Ops.ModifyUnit mod
                = p as ANWI.Messaging.Ops.ModifyUnit;

            ActiveOperation op = GetOperation(mod.opUUID);

            if (op != null)
            {
                op.ModifyUnit(mod);
            }

            return(null);
        }
Example #10
0
        ProcessAssignUser(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Ops.AssignUser au
                = p as ANWI.Messaging.Ops.AssignUser;

            ActiveOperation op = GetOperation(au.opUUID);

            if (op != null)
            {
                op.ChangeAssignment(au.positionUUID, au.userId);
            }

            return(null);
        }
Example #11
0
        ProcessDeletePosition(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Ops.DeletePosition del
                = p as ANWI.Messaging.Ops.DeletePosition;

            ActiveOperation op = GetOperation(del.opUUID);

            if (op != null)
            {
                op.DeletePosition(del.posUUID);
            }

            return(null);
        }
Example #12
0
        ProcessDeleteOOBElement(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Ops.DeleteOOBElement del
                = p as ANWI.Messaging.Ops.DeleteOOBElement;

            ActiveOperation op = GetOperation(del.opUUID);

            if (op != null)
            {
                op.DeleteFleetUnit(del.elementUUID);
            }

            return(null);
        }
        public async Task <List <IDictionary <string, object> > > ExecuteOperation(ActiveOperation ops, List <Dictionary <string, object> > records)
        {
            // TODO
            // 1) Read file content from blob storage
            // 2> Return List from excel data
            List <IDictionary <string, object> > list = new List <IDictionary <string, object> >();
            List <string> columns = new List <string>();

            dynamic payload;
            dynamic script;

            if (ops != null)
            {
                payload = JsonConvert.DeserializeObject(ops.Content);
                // script = JsonConvert.DeserializeObject(ops.Script);

                foreach (var property in payload)
                {
                    foreach (var property1 in property)
                    {
                        columns.Add(property1.Name.ToLower());
                    }
                }
            }

            foreach (var item in records)
            {
                IDictionary <string, object> objectFields = new ExpandoObject();

                // Iterate through fields and populate dynamic object.
                foreach (KeyValuePair <string, object> f in item)
                {
                    if (columns.Contains(f.Key.ToLower()))
                    {
                        objectFields.Add(f.Key, f.Value);
                    }
                }

                list.Add(objectFields);
            }

            return(list);
        }
Example #14
0
        public async Task <IEnumerable <Dictionary <string, object> > > ExecuteSourceOperation(ActiveOperation ops)
        {
            // TODO
            // 1) Read file content from blob storage
            // 2> Return List from excel data

            var intermediateJson = JsonConvert.DeserializeObject <string>(ops.Content);
            var content          = JsonConvert.DeserializeObject <ExcelDocument>(intermediateJson);

            using (var da = new DocumentDataAccess(_conStr))
            {
                var doc = await da.Get(Convert.ToInt32(content.DocumentId));

                if (doc != null)
                {
                    var bs          = new BlobStorageService(blobContainer);
                    var blobContent = await bs.GetBlob(doc.WebUrl);

                    var excelData = new ExcelManager().ExtractData(blobContent);

                    return(excelData);
                }
            }

            return(null);
        }
Example #15
0
        ProcessRequestMessage(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Request req = p as ANWI.Messaging.Request;

            switch (req.type)
            {
            case ANWI.Messaging.Request.Type.GetOperations: {
                List <LiteOperation> ops
                    = OperationManager.Instance.GetOpsList(
                          GetUser().profile.id
                          );
                return(new ANWI.Messaging.FullOperationsList(ops));
            }

            case ANWI.Messaging.Request.Type.GetOperation: {
                ANWI.Messaging.ReqExp.IdString det
                    = req.detail as ANWI.Messaging.ReqExp.IdString;

                ActiveOperation op = GetOperation(det.str);
                if (op != null)
                {
                    subscribedOps.Add(det.str);
                    op.SubscribeUser(GetUser());
                    return(new ANWI.Messaging.Ops.FullOperationSnapshot(
                               op.ToSnapshot()));
                }
                else
                {
                    return(null);
                }
            }

            case ANWI.Messaging.Request.Type.CloseOperation: {
                ANWI.Messaging.ReqExp.IdString det
                    = req.detail as ANWI.Messaging.ReqExp.IdString;

                subscribedOps.Remove(det.str);

                ActiveOperation op = GetOperation(det.str);
                if (op != null)
                {
                    op.UnsubscribeUser(GetTokenCookie());
                }

                return(null);
            }

            case ANWI.Messaging.Request.Type.AdvanceOpLifecycle: {
                ANWI.Messaging.ReqExp.IdString det
                    = req.detail as ANWI.Messaging.ReqExp.IdString;

                ActiveOperation op = GetOperation(det.str);
                if (op != null)
                {
                    op.AdvanceLifecycle();
                }
                return(null);
            }

            case ANWI.Messaging.Request.Type.JoinOperation: {
                ANWI.Messaging.ReqExp.IdString det
                    = req.detail as ANWI.Messaging.ReqExp.IdString;

                ActiveOperation op = GetOperation(det.str);
                if (op != null)
                {
                    op.JoinUser(GetTokenCookie());
                }
                return(null);
            }

            case ANWI.Messaging.Request.Type.LeaveOperation: {
                ANWI.Messaging.ReqExp.IdString det
                    = req.detail as ANWI.Messaging.ReqExp.IdString;

                ActiveOperation op = GetOperation(det.str);
                if (op != null)
                {
                    op.RemoveUser(det.id);
                }
                return(null);
            }
            }

            return(null);
        }
 private void onMouseDown(object sender, MouseButtonEventArgs e)
 {
     ActiveOperation.Start(sender);
 }
        internal async Task PlayAdAsync(IAdSource adSource, TimeSpan? startTimeout, CancellationToken cancellationToken, IProgress<AdStatus> progress)
#endif
        {
            if (!(adSource.Payload is AdDocumentPayload)) throw new ArgumentException("adSource must contain a payload of type AdDocumentPayload", "adPayload");
            var adDoc = (AdDocumentPayload)adSource.Payload;
            
            // do an extra check to catch an empty payload before we get any further.
            if (adDoc.AdPods.Count == 0)
            {
                VpaidController.TrackErrorUrl(adDoc.Error, Microsoft.Media.Advertising.VpaidController.Error_NoAd);
                var playExection = new PlayException(new LoadException(new Exception("No ads found.")));
                LogError(adSource, playExection);
                throw playExection;
            }

            // create a new token that we can cancel independently
            var masterCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
            var playTasks = PlayAdAsync(adDoc, adSource, startTimeout, masterCancellationToken.Token, progress);
            try
            {
                activeOperation = new ActiveOperation(playTasks.Secondary, masterCancellationToken);
                await playTasks.Primary;
            }
            catch (PlayException)
            {
                activeOperation = null;
                throw;
            }
        }
 private void onMouseUp(object sender, MouseButtonEventArgs e)
 {
     ActiveOperation.Finish();
 }