Exemplo n.º 1
0
        void ITemplate.InstantiateIn(System.Web.UI.Control container)
        {
            switch (_templateType)
            {
            case ListItemType.Header: {
                _iField++;

                if (_typeCtrl != TypeTemplateCol.action && _typeCtrl != TypeTemplateCol.action_url &&
                    _typeCtrl != TypeTemplateCol.request && _typeCtrl != TypeTemplateCol.tabledel &&
                    _typeCtrl != TypeTemplateCol.tablelink)
                {
                    html_ctrl fld = new html_ctrl("div", new attrs(new string[, ] {
                            { "class", "header-col" }
                        }));

                    // titolo colonna
                    attrs atrs = new attrs(new string[, ] {
                            { "colgrid", "true" }, { "oncontextmenu", "col_contextmenu('" + _grid_id + "', '" + _fld_name + "')" }
                        });
                    XmlNode h_node  = refHeader();
                    ctrl    c_title = h_node != null ? (ctrl) new link(_col_title, xmlDoc.node_val(h_node, "title") != "" ? xmlDoc.node_val(h_node, "title") : _col_des, "title-col"
                                                                       , _page.page.parse(h_node.Attributes["ref"].Value), atrs) : (ctrl) new label(_col_title, "title-col", _col_des, atrs);
                    fld.add(c_title.control);

                    // freccine ordinamento
                    string direction;
                    bool   sorted = grid_ctrl.find_sort_field(grid_ctrl.xmlOfGrid(_page, _grid_id), _fld_name, out direction);
                    ctrl   f_ctrl = new div(null, "<div class='arrows' title=\".\" "
                                            + " field_name='" + _fld_name + "' onclick=\"updateGridSort('" + _grid_id + "', '" + _fld_name + "')\" oncontextmenu=\"col_contextmenu('" + _grid_id + "', '" + _fld_name + "')\">"
                                            + (!sorted ? "<a class='mif-arrow-up arrow-col'></a>" : (direction.ToLower() == "asc" ? "<a class='mif-arrow-up arrow-col-active'></a>"
                : "<a class='mif-arrow-down arrow-col-active'></a>")) + "</div>");
                    fld.add(f_ctrl.control);

                    container.Controls.Add(fld.control);
                }
            }
            break;

            case ListItemType.Item: {
                _iField++;

                // creazione del controllo
                WebControl ctrl           = null;
                bool       notTransparent = false;
                if (_typeCtrl == TypeTemplateCol.text)
                {
                    ctrl = refItem() != null ?
                           new link(new EventHandler(textlink_DataBinding)).w_ctrl : new text(new EventHandler(text_DataBinding), true).w_ctrl;
                }
                else if (_typeCtrl == TypeTemplateCol.integer)
                {
                    ctrl = refItem() != null ?
                           new link(new EventHandler(intlink_DataBinding)).w_ctrl : new label(new EventHandler(int_DataBinding)).lbl;
                }
                else if (_typeCtrl == TypeTemplateCol.euro)
                {
                    ctrl = refItem() != null ?
                           new link(new EventHandler(eurolink_DataBinding)).w_ctrl : new label(new EventHandler(euro_DataBinding)).lbl;
                }
                else if (_typeCtrl == TypeTemplateCol.real)
                {
                    ctrl = refItem() != null ?
                           new link(new EventHandler(reallink_DataBinding)).w_ctrl : new label(new EventHandler(real_DataBinding)).lbl;
                }
                else if (_typeCtrl == TypeTemplateCol.check)
                {
                    ctrl = new check(_page.newIdControl, new EventHandler(check_DataBinding), false).w_ctrl;
                }
                else if (_typeCtrl == TypeTemplateCol.date || _typeCtrl == TypeTemplateCol.date_hour)
                {
                    if (refItem() != null)
                    {
                        throw new Exception("refitem non supportato per la colonna 'date'");
                    }
                    else
                    {
                        ctrl = new label(new EventHandler(date_DataBinding)).lbl;
                    }
                }
                else if (_typeCtrl == TypeTemplateCol.link)
                {
                    ctrl = new link(new EventHandler(link_DataBinding)).w_ctrl;
                }
                else if (_typeCtrl == TypeTemplateCol.action)
                {
                    notTransparent = true;
                    ctrl           = new link(new EventHandler(action_DataBinding), _icon + " icon-btn").w_ctrl;
                }
                else if (_typeCtrl == TypeTemplateCol.action_url)
                {
                    notTransparent = true;
                    ctrl           = new link(new EventHandler(actionurl_DataBinding), _icon + " icon-btn").w_ctrl;
                }
                else if (_typeCtrl == TypeTemplateCol.request)
                {
                    notTransparent = true;
                    ctrl           = new link(new EventHandler(request_DataBinding), _icon + " icon-btn").w_ctrl;
                }
                else if (_typeCtrl == TypeTemplateCol.tabledel)
                {
                    notTransparent = true;
                    ctrl           = new link(new EventHandler(requestDel_DataBinding), _icon + " icon-btn").w_ctrl;
                }
                else if (_typeCtrl == TypeTemplateCol.tablelink)
                {
                    notTransparent = true;
                    ctrl           = new link(new EventHandler(requestLink_DataBinding), _icon + " icon-btn").w_ctrl;
                }
                else
                {
                    throw new Exception("campo '" + _typeCtrl.ToString() + "' non supportato!");
                }

                // aggiunta controllo alla griglia
                if (ctrl != null)
                {
                    if (_typeCtrl == TypeTemplateCol.action || _typeCtrl == TypeTemplateCol.action_url ||
                        _typeCtrl == TypeTemplateCol.request || _typeCtrl == TypeTemplateCol.tabledel ||
                        _typeCtrl == TypeTemplateCol.tablelink)
                    {
                        ctrl.ToolTip = _col_des;
                    }
                    if (xmlDoc.node_bool(_colNode, "show_title"))
                    {
                        ctrl.Attributes.Add("show_title", "true");
                    }
                    ctrl.Style.Add(HtmlTextWriterStyle.Width, "95%");
                    if (!notTransparent)
                    {
                        ctrl.Style.Add(HtmlTextWriterStyle.BackgroundColor, "transparent");
                    }
                    container.Controls.Add(ctrl);
                }
            }
            break;

            case ListItemType.EditItem:
                //...
                break;

            case ListItemType.Footer: {
                _iField++;

                // creazione del controllo
                WebControl ctrl = null;
                if (_typeCtrl == TypeTemplateCol.euro)
                {
                    ctrl = new label(new EventHandler(eurosum_DataBinding)).lbl;
                }
                else if (_typeCtrl == TypeTemplateCol.real)
                {
                    ctrl = new label(new EventHandler(realsum_DataBinding)).lbl;
                }
                else
                {
                    throw new Exception("campo '" + _typeCtrl.ToString() + "' non supportato!");
                }

                // aggiunta controllo alla griglia
                if (ctrl != null)
                {
                    ctrl.ToolTip = _col_des;
                    ctrl.Style.Add(HtmlTextWriterStyle.Width, "95%");
                    ctrl.Style.Add(HtmlTextWriterStyle.BackgroundColor, "transparent");
                    container.Controls.Add(ctrl);
                }
            }
            break;
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //WebSocket socket = new WebSocket();
            //socket.subscribeAllEvents();

            XooaClient client = new XooaClient();

            client.setApiToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcGlLZXkiOiJIU0E0SkZRLUFHUjQ0NUstSkcwOUMzMi1CUDgyVDRZIiwiQXBpU2VjcmV0IjoiS2JZSzdDVHVaWThZSk9aIiwiUGFzc3BocmFzZSI6IjA1N2M2ODM3NjgyZDBjODBkMTllYTk0NjliYzI0MzczIiwiaWF0IjoxNTQzOTkzNjIzfQ.BkNZ6N5FfjCdYsAOYisFSelUDftDhnY3f8OYf4EgXYc");

            //client.subscribeAllEvents((data) => {
            //    Console.WriteLine("data - ", data.ToString());
            //});

            try {
                Console.WriteLine("----- Start -----");

                Console.WriteLine("----- Validate -----");

                client.validate().display();

                Console.WriteLine();

                Console.WriteLine("----- Current Block -----");

                client.getCurrentBlock().display();

                Console.WriteLine();

                Console.WriteLine("----- Current Block Async -----");

                PendingTransactionResponse currentBlockResponse = client.getCurrentBlockAsync();
                currentBlockResponse.display();

                Console.WriteLine();

                Console.WriteLine("----- Current Block From Result Id -----");

                client.getResultForCurrentBlock(currentBlockResponse.getResultId()).display();

                Console.WriteLine();

                Console.WriteLine("----- Block by Number -----");

                client.getBlockByNumber("10").display();

                Console.WriteLine();

                Console.WriteLine("----- Block by NUmber Async -----");

                PendingTransactionResponse blockByNumber = client.getBlockByNumberAsync("10");
                blockByNumber.display();

                Console.WriteLine();

                Console.WriteLine("----- Block Data from Result Id -----");

                client.getResultForBlockByNumber(blockByNumber.getResultId()).display();

                Console.WriteLine();

                Console.WriteLine("----- Invoke -----");

                string[] invokeargs = { "argsx", "200" };

                client.invoke("set", invokeargs).display();

                Console.WriteLine();

                Console.WriteLine("----- Query -----");

                string[] queryArgs = { "argsx" };

                client.query("get", queryArgs).display();

                Console.WriteLine();

                Console.WriteLine("----- Invoke Async -----");

                string[] invokeargs2 = { "argsx", "400" };

                PendingTransactionResponse invokeResponse = client.invokeAsync("set", invokeargs2);
                invokeResponse.display();
                Thread.Sleep(4000);

                Console.WriteLine();

                Console.WriteLine("----- Invoke from Result Id -----");

                client.getResultForInvoke(invokeResponse.getResultId()).display();

                Console.WriteLine();

                Console.WriteLine("----- Query Async -----");

                PendingTransactionResponse queryResponse = client.queryAsync("get", queryArgs);
                queryResponse.display();

                Console.WriteLine();

                Console.WriteLine("----- Query from Result ID -----");

                client.getResultForQuery(queryResponse.getResultId()).display();

                Console.WriteLine();

                Console.WriteLine("----- Current Identity -----");

                client.currentIdentity().display();

                Console.WriteLine();

                Console.WriteLine("----- Get All Identities -----");

                List <IdentityResponse> identities = client.getIdentities();
                foreach (IdentityResponse identity in identities)
                {
                    identity.display();
                    Console.WriteLine();
                }

                Console.WriteLine("----- Enroll Identity -----");

                attrs Attrib = new attrs("Name", "Value", false);

                List <attrs> attributes = new List <attrs>();
                attributes.Add(Attrib);

                IdentityRequest idReq = new IdentityRequest("Kavi", "r", false, attributes);

                IdentityResponse newIdentity1 = client.enrollIdentity(idReq);
                newIdentity1.display();

                Console.WriteLine();

                Console.WriteLine("----- Enroll Identity Async -----");

                PendingTransactionResponse pendingIdentity = client.enrollIdentityAsync(idReq);
                pendingIdentity.display();

                Console.WriteLine();

                Console.WriteLine("----- New Identity from Result Id -----");

                IdentityResponse newIdentity2 = client.getResultForIdentity(pendingIdentity.getResultId());
                newIdentity2.display();

                Console.WriteLine();

                Console.WriteLine("----- Regenerate New API Token -----");

                IdentityResponse newTokenId = client.regenerateIdentityApiToken(newIdentity1.getId());
                newTokenId.display();

                Console.WriteLine();

                Console.WriteLine("----- Get Identity -----");

                client.getIdentity(newTokenId.getId()).display();

                Console.WriteLine();

                Console.WriteLine("----- Delete Identity -----");

                string deleted1 = client.deleteIdentity(newIdentity2.getId());
                Console.WriteLine(deleted1);
                string deleted2 = client.deleteIdentity(newIdentity1.getId());
                Console.WriteLine(deleted2);

                Console.WriteLine();

                Console.WriteLine("----- End -----");
            } catch (XooaApiException xae) {
                xae.display();
            } catch (XooaRequestTimeoutException xrte) {
                xrte.display();
            }
            //Console.ReadLine();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get IdentityResponse data for the Result Id.
        /// </summary>
        /// <exception cref="Xooa.Client.Exception.XooaApiException">Thrown when fails to make API call</exception>
        /// <param name="resultId">Result Id of the transaction to fetch data.</param>
        /// <param name="timeout">Timeout interval for transaction.</param>
        /// <returns>IdentityResponse giving the data about the Identity request.</returns>
        public IdentityResponse getResultForIdentity(string resultId, string timeout = "3000")
        {
            Log.Info("Invoking URL - " + XooaConstants.RESULT_URL);

            var localVarPath = XooaConstants.RESULT_URL;
            var contentType  = XooaConstants.CONTENT_TYPE;

            var localVarQueryParameters = new List <KeyValuePair <string, string> >();

            localVarQueryParameters.Add(new KeyValuePair <string, string>(XooaConstants.ASYNC, XooaConstants.FALSE));
            localVarQueryParameters.Add(new KeyValuePair <string, string>(XooaConstants.TIMEOUT, timeout));

            var localVarHeaderParams = new Dictionary <string, string>();

            localVarHeaderParams.Add(XooaConstants.ACCEPT, XooaConstants.CONTENT_TYPE);
            localVarHeaderParams.Add(XooaConstants.AUTHORIZATION, XooaConstants.TOKEN + ApiToken);

            var localVarPathParams = new Dictionary <string, string>();

            localVarPathParams.Add("ResultId", resultId);

            int statusCode = 0;

            try {
                RestRequest request = XooaSDK.Client.Util.Request.PrepareRequest(localVarPath,
                                                                                 RestSharp.Method.GET, localVarQueryParameters, null, localVarHeaderParams,
                                                                                 null, localVarPathParams, contentType);

                IRestResponse response = RestClient.Execute(request);

                JObject details = XooaSDK.Client.Util.Request.GetData(response);

                var payload = details["result"];
                var Attrs   = payload["Attrs"];

                List <attrs> attributes = new List <attrs>();

                foreach (var attrObject in Attrs)
                {
                    attrs attr = new attrs(attrObject["name"].ToString(),
                                           attrObject["value"].ToString(), (bool)attrObject["ecert"]);

                    attributes.Add(attr);
                }

                IdentityResponse identityResponse = new IdentityResponse(
                    (payload["IdentityName"].ToString() != null) ? payload["IdentityName"].ToString() : "",
                    (payload["Access"].ToString() != null) ? payload["Access"].ToString() : "",
                    (bool)payload["canManageIdentities"],
                    (payload["createdAt"].ToString() != null) ? payload["createdAt"].ToString() : "",
                    (payload["ApiToken"].ToString() != null) ? payload["ApiToken"].ToString() : "",
                    (payload["Id"].ToString() != null) ? payload["Id"].ToString() : "",
                    attributes);

                return(identityResponse);
            } catch (XooaRequestTimeoutException xrte) {
                Log.Error(xrte);
                throw xrte;
            } catch (XooaApiException xae) {
                Log.Error(xae);
                throw xae;
            } catch (System.Exception e) {
                Log.Error(e);
                throw new XooaApiException(statusCode, e.Message);
            }
        }