private bool ValidateTransaction(EndpointVersionType endpointVersion, NodeMethod transactionWebMethod,
                                         ComplexContent content, bool doValidateFlowOperation,
                                         string flowId, out string networkId)
        {
            networkId = null;
            string            dbOperation;
            NodeMethod        webMethod;
            bool              isNetworkTransactionId = false;
            string            transactionFlowId;
            TransactionStatus transactionStatus =
                TransactionManager.GetTransactionStatus(content.Transaction.Id, out transactionFlowId,
                                                        out dbOperation, out webMethod);

            if (transactionStatus == null)
            {
                transactionStatus =
                    TransactionManager.GetTransactionStatusByNetworkId(content.Transaction.Id, out transactionFlowId,
                                                                       out dbOperation, out webMethod);
                if (transactionStatus == null)
                {
                    throw FaultProvider.GetFault(endpointVersion, ENExceptionCodeType.E_TransactionId,
                                                 "Transaction \"{0}\" was not found",
                                                 content.Transaction.Id);
                }
                isNetworkTransactionId = true;
            }
            if (transactionFlowId != flowId)
            {
                throw FaultProvider.GetFault(endpointVersion, ENExceptionCodeType.E_InvalidDataflow,
                                             "Flow operation \"{0}\" is not valid for transaction \"{1}\"",
                                             content.Flow.Operation, content.Transaction.Id);
            }
            if (doValidateFlowOperation &&
                !string.Equals(dbOperation, content.Flow.Operation ?? string.Empty, StringComparison.InvariantCultureIgnoreCase))
            {
                throw FaultProvider.GetFault(endpointVersion, ENExceptionCodeType.E_InvalidDataflow,
                                             "Flow operation \"{0}\" is not valid for transaction \"{1}\"",
                                             content.Flow.Operation, content.Transaction.Id);
            }
            if ((transactionWebMethod == NodeMethod.Submit) && (webMethod != NodeMethod.Submit))
            {
                // Create new transaction and reference the input transaction id as the network id for
                // the new transcation
                networkId = content.Transaction.Id;
            }
            if (networkId != null)
            {
                content.Transaction.Id = string.Empty;
                return(true);
            }
            else
            {
                if (isNetworkTransactionId)
                {
                    // Use the "real" db transcation id
                    content.Transaction.Id = transactionStatus.Id;
                }
                return(false);
            }
        }
Пример #2
0
        Button CreateItem(int bitmap_id, string text, Rect bounds,
                          float x, float y)
        {
            ComplexContent cc       = new ComplexContent(null);
            int            size     = (int)(110 * GameView.scaleFactor);
            Bitmap         bitmap   = BitmapLoader.LoadAndResize(bitmap_id, size, size);
            BitmapContent  bContent = new BitmapContent(bitmap, cc.pivot);
            TextContent    tContent = new TextContent(text, ColorBank.Red,
                                                      50 * GameView.scaleFactor, cc.pivot, 0, 120 * GameView.scaleFactor);

            cc.contents.Add(bContent);
            cc.contents.Add(tContent);
            return(new Button(cc, bounds, pivot, x, y));
        }
Пример #3
0
        Button CreateDifficultyButton(int res_id, string text, float x, float y)
        {
            int           size = (int)(128 * GameView.scaleFactor);
            Bitmap        b    = BitmapLoader.LoadAndResize(res_id, size, size);
            BitmapContent bc   = new BitmapContent(b, null, 0, 0);
            TextContent   tc   = new TextContent(text, ColorBank.Red, 44 * GameView.scaleFactor,
                                                 null, 0, 110 * GameView.scaleFactor);
            ComplexContent cc = new ComplexContent(null, 0, 0);

            cc.contents.Add(bc);
            cc.contents.Add(tc);
            int  h      = (int)(100 * GameView.scaleFactor);
            int  vup    = (int)(-90 * GameView.scaleFactor);
            int  vdown  = (int)(150 * GameView.scaleFactor);
            Rect bounds = new Rect(-h, vup, h, vdown);

            return(new Button(cc, bounds, pivot, x, y));
        }
Пример #4
0
        // ------------------------------------------------------------------
        // Make sure that complex content is enabled.
        // ------------------------------------------------------------------
        private void EnsureComplexContent(ITextContainer textContainer)
        {
            if (_complexContent == null)
            {
                if (textContainer == null)
                {
                    textContainer = new TextContainer(IsContentPresenterContainer ? null : this, false /* plainTextOnly */);
                }

                _complexContent = new ComplexContent(this, textContainer, false, Text);
                _contentCache = null;

                if (CheckFlags(Flags.FormattedOnce))
                {
                    // If we've already measured at least once, hook up the TextContainer
                    // listeners now.
                    Invariant.Assert(!CheckFlags(Flags.PendingTextContainerEventInit));
                    InitializeTextContainerListeners();

                    // Line layout data cached up to this point will become invalid
                    // becasue of content structure change (implicit Run added).
                    // So we need to clear the cache - we call InvalidateMeasure for this
                    // purpose. However, we do not want to produce a side effect
                    // of making layout invalid as a result of touching ContentStart/ContentEnd
                    // and other properties. For that we need to UpdateLayout when it was
                    // dirtied by our switch.
                    bool wasLayoutValid = this.IsMeasureValid && this.IsArrangeValid;
                    InvalidateMeasure();
                    InvalidateVisual(); //ensure re-rendering too
                    if (wasLayoutValid)
                    {
                        UpdateLayout();
                    }
                }
                else
                {
                    // Otherwise, wait until our first measure.
                    // This lets us skip the work for all content invalidation
                    // during load, before the first measure.
                    SetFlags(true, Flags.PendingTextContainerEventInit);
                }
            }
        }
Пример #5
0
        public SingleGameRunupScene() : base()
        {
            int         rw        = (int)(170 * GameView.scaleFactor);
            int         rh        = (int)(80 * GameView.scaleFactor);
            Rect        r         = new Rect(-rw, -rh, rw, rh);
            RectContent rect      = new RectContent(r);
            TextContent startText = new TextContent("START", ColorBank.Red,
                                                    70 * GameView.scaleFactor, null);
            ComplexContent startCC = new ComplexContent(null);

            startCC.contents.Add(rect);
            startCC.contents.Add(startText);
            startButton          = new Button(startCC, r, pivot);
            startButton.Pressed += () =>
            {
                SingleGameScene.Instance.InitGame(logic);
                SingleGameScene.Instance.Show(Side.Right);
                Hide(Side.Left);
            };

            processingText = new TextContent("PROCESSING...", ColorBank.Red,
                                             50 * GameView.scaleFactor, pivot, 0, -250 * GameView.scaleFactor);

            loading = new LoadingIndicator((int)(100 * GameView.scaleFactor), pivot, 0, 0);

            easyButton = CreateDifficultyButton(Resource.Drawable.brain_easy, "EASY",
                                                -240 * GameView.scaleFactor, 300 * GameView.scaleFactor);
            easyButton.Pressed += () =>
            {
                lineSwitch.CurrentState  = 0;
                SingleGameLogic.BotDepth = 0;
            };

            normalButton = CreateDifficultyButton(Resource.Drawable.brain_normal, "NORMAL",
                                                  0 * GameView.scaleFactor, 300 * GameView.scaleFactor);
            normalButton.Pressed += () =>
            {
                lineSwitch.CurrentState  = 1;
                SingleGameLogic.BotDepth = 2;
            };

            hardButton = CreateDifficultyButton(Resource.Drawable.brain_hard, "HARD",
                                                240 * GameView.scaleFactor, 300 * GameView.scaleFactor);
            hardButton.Pressed += () =>
            {
                lineSwitch.CurrentState  = 2;
                SingleGameLogic.BotDepth = 4;
            };

            lineSwitch = new HLineSwitch((int)(720 * GameView.scaleFactor),
                                         (int)(200 * GameView.scaleFactor), 3, SingleGameLogic.BotDepth / 2,
                                         pivot, 0, 460 * GameView.scaleFactor);

            int    size       = (int)(90 * GameView.scaleFactor);
            Bitmap backBitmap = BitmapLoader.LoadAndResize(Resource.Drawable.back,
                                                           size, size);
            BitmapContent backContent = new BitmapContent(backBitmap, null);
            int           hb          = (int)(80 * GameView.scaleFactor);

            backButton = new Button(backContent, new Rect(-hb, -hb, hb, hb),
                                    pivot, -265 * GameView.scaleFactor, -380 * GameView.scaleFactor);
            backButton.Pressed += () =>
            {
                ChoiceScene.Instance.Show(Side.Left);
                Hide(Side.Right);
            };
        }
Пример #6
0
        /// <summary>
        /// Download
        /// </summary>
        /// <param name="securityToken"></param>
        /// <param name="transactionId"></param>
        /// <param name="dataflow"></param>
        /// <param name="documents"></param>
        void INetworkNodeBinding.Download(string securityToken, string transactionId, string dataflow, ref NodeDocument[] documents)
        {
            Init();
            LOG.Debug("Download");

            if (string.IsNullOrEmpty(transactionId))
            {
                throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ENExceptionCodeType.E_InvalidParameter,
                                                                "NULL Transaction Id");
            }

            try
            {
                SoapContext res = HttpSoapContext.ResponseContext;

                LOG.Debug("Getting visit");
                NamedEndpointVisit visit = _service11Provider.VisitProvider.GetVisit(securityToken);

                ComplexContent content = new ComplexContent();
                if (!string.IsNullOrEmpty(dataflow))
                {
                    content.Flow = new OperationDataFlow(dataflow);
                }
                content.Transaction = new SimpleId(transactionId);

                LOG.Debug("Submitting: " + content);
                IList <Document> wnosDocs = _service11Provider.ContentService.Download(content, visit);


                List <NodeDocument> wsdlDocList = new List <NodeDocument>();

                if (!CollectionUtils.IsNullOrEmpty(wnosDocs))
                {
                    Dictionary <string, string> docIdList = new Dictionary <string, string>();

                    LOG.Debug("Spooling documents");
                    foreach (Document wnosDoc in wnosDocs)
                    {
                        NodeDocument doc = new NodeDocument();

                        doc.content = wnosDoc.Content;
                        doc.type    = CommonContentAndFormatProvider.ConvertTo11Enum(wnosDoc.Type);
                        doc.name    = wnosDoc.DocumentName;
                        LOG.Debug("   doc:" + doc);

                        DimeAttachment attachment = new DimeAttachment();
                        attachment.Stream     = new MemoryStream(doc.content);
                        attachment.TypeFormat = TypeFormatEnum.MediaType;
                        attachment.Type       = "application/x-gzip";
                        attachment.Id         = Guid.NewGuid().ToString();

                        //Add to the the xref filter collection
                        docIdList.Add(doc.name, attachment.Id);

                        res.Attachments.Add(attachment);
                        wsdlDocList.Add(doc);
                    }
                    //Output filter specific
                    res.Add("hrefs", docIdList);
                }

                documents = wsdlDocList.ToArray();
            }
            catch (Exception ex)
            {
                LOG.Error("Error while downloading", ex);
                throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ex);
            }
        }
        public IList <Document> Download(ComplexContent content, NamedEndpointVisit visit)
        {
            Activity activity = null;

            try
            {
                // Validate inputs
                NodeVisit nodeVisit;
                MakeEndpointActivity(visit, ActivityType.Audit, NodeMethod.Download,
                                     out nodeVisit, out activity);

                if (content == null)
                {
                    throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_InvalidParameter,
                                                 "Input content is null");
                }
                if ((content.Transaction == null) || string.IsNullOrEmpty(content.Transaction.Id))
                {
                    throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_InvalidParameter,
                                                 "Input transaction is null");
                }
                bool   isFlowProtected;
                string flowName, flowOperation;
                string flowId = TransactionManager.GetTransactionFlowId(content.Transaction.Id, out flowName, out flowOperation,
                                                                        out isFlowProtected);
                if (flowId == null)
                {
                    throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_InvalidDataflow,
                                                 "A flow with transaction id \"{0}\" was not found", content.Transaction.Id);
                }
                if ((content.Flow != null) && !string.IsNullOrEmpty(content.Flow.FlowName))
                {
                    if (!string.Equals(flowName, content.Flow.FlowName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_InvalidDataflow,
                                                     "The input dataflow name \"{0}\" does not match the dataflow name for transaction id \"{1}\"",
                                                     content.Flow.FlowName, content.Transaction.Id);
                    }
                }
                if (content.Flow == null)
                {
                    content.Flow = new OperationDataFlow(flowName);
                }
                else if (string.IsNullOrEmpty(content.Flow.FlowName))
                {
                    content.Flow.FlowName = flowName;
                }
                activity.FlowName  = content.Flow.FlowName;
                activity.Operation = content.Flow.Operation;
                string networkId;
                ValidateTransaction(visit.Version, NodeMethod.Download, content, false, flowId,
                                    out networkId);
                activity.TransactionId = content.Transaction.Id;
                if (isFlowProtected)
                {
                    ValidateUserPermissions(nodeVisit, content.Flow.FlowName, content.Flow.Operation,
                                            NodeMethod.Download, activity);
                }

                IList <Document> documents;
                try
                {
                    documents = DocumentManager.GetDocuments(content.Transaction.Id,
                                                             content.Documents, true);
                }
                catch (FileNotFoundException fileNotFoundException)
                {
                    throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_FileNotFound,
                                                 string.Format("The document \"{0}\" was not found.",
                                                               Path.GetFileName(fileNotFoundException.FileName)));
                }

                if (!CollectionUtils.IsNullOrEmpty(documents))
                {
                    foreach (Document document in documents)
                    {
                        activity.AppendFormat("Document: {0}.", document);
                    }
                }

                NotificationManager.DoDownloadNotifications(content.Transaction.Id, flowId, content.Flow.FlowName,
                                                            nodeVisit.Account.NaasAccount);
                return(documents);
            }
            catch (Exception ex)
            {
                if (activity != null)
                {
                    activity.Append(ExceptionUtils.ToShortString(ex));
                    activity.Type = ActivityType.Error;
                }
                if (ex is SoapException)
                {
                    throw;      // Throw directly since already SoapException
                }
                else
                {
                    throw FaultProvider.GetFault(visit.Version, ex);
                }
            }
            finally
            {
                if (activity != null)
                {
                    ActivityManager.Log(activity);
                }
            }
        }