public ActionResult Edit(int idPlan)
        {
            WSRequest request = new WSRequest("plans/" + idPlan);

            request.AddAuthorization(Session["token"].ToString());
            var response = request.Get();

            if (response.Code != 200)
            {
                ModelState.AddModelError("", "Não foi possível buscar esse plano");

                return(RedirectToAction("Index", "Plan"));
            }
            var body = response.Body;

            var model = new PlanViewModel
            {
                IdPlan      = (int)body["id_plan"],
                Name        = body["name"].ToString(),
                Left        = (int)body["left"],
                Price_cents = (int)body["price_cents"],
                Rewards     = body["rewards"].ToString(),
            };

            return(View(model));
        }
        public ActionResult Create(PlanViewModel plan)
        {
            if (ModelState.IsValid)
            {
                WSRequest request = new WSRequest("/plans");
                request.AddAuthorization(Session["token"].ToString());
                IEnumerable <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("name", plan.Name),
                    //new KeyValuePair<string, string>("id_plan", plan.IdPlan.ToString()),
                    new KeyValuePair <string, string>("left", plan.Left.ToString()),
                    new KeyValuePair <string, string>("price_cents", plan.Price_cents.ToString()),
                    new KeyValuePair <string, string>("rewards", plan.Rewards),
                };

                request.AddJsonParameter(parameters);

                var response = request.Post();

                if (response.Code != 201)
                {
                    ModelState.AddModelError("", response.Code + ":" + response.Body.GetValue("Message").ToString());
                }
                else
                {
                    //return RedirectToAction("Show", "Plan", new { idPlan = response.Body.GetValue("id_plan") });
                    return(RedirectToAction("Index", "Plan", new { idPlan = plan.IdPlan }));
                }
            }
            return(View("New", plan)); //RedirectToAction("New", "Plan", new { error = "Não foi possivel cadastrar" });
        }
        public ActionResult Update(PlanViewModel plan)
        {
            WSRequest request = new WSRequest("/plans/" + plan.IdPlan);

            request.AddAuthorization(Session["token"].ToString());
            IEnumerable <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("name", plan.Name),
                new KeyValuePair <string, string>("left", plan.Left.ToString()),
                new KeyValuePair <string, string>("price_cents", plan.Price_cents.ToString()),
                new KeyValuePair <string, string>("rewards", plan.Rewards),
            };

            request.AddJsonParameter(parameters);

            var response = request.Put();

            if (response.Code != 204)
            {
                return(RedirectToAction("Edit", "Plan", plan));
            }

            return(RedirectToAction("Show", "Plan", new
            {
                idPlan = plan.IdPlan,
                message = string.Format("O plano {0} - {1} foi atualizado", plan.IdPlan, plan.Name)
            }));
        }
        public ActionResult Show(int idPlan)
        {
            WSRequest request = new WSRequest("plans/" + idPlan);

            request.AddAuthorization(Session["token"].ToString());
            var response = request.Get();

            if (response.Code != 200)
            {
                return(RedirectToAction("Index", "Home", new { message = "Não foi possível buscar esse plano" }));
            }
            var body = response.Body;
            //var js = new Newtonsoft.Json.JsonSerializer();
            //var mod=js.Deserialize(new System.IO.StringReader(body.ToString()), typeof(PlanViewModel));

            var model = new PlanViewModel
            {
                IdPlan      = (int)body["id_plan"],
                Name        = body["name"].ToString(),
                Left        = (int)body["left"],
                Price_cents = (int)body["price_cents"],
                Rewards     = body["rewards"].ToString(),
            };

            return(View(model));
        }
Esempio n. 5
0
        /// <summary>
        /// 打开视频窗口
        /// </summary>
        /// <param name="request"></param>
        private void procVideo_OpenWindow(WSRequest request)
        {
            var req = JsonConvert.DeserializeObject <WSVideoRequest_OpenWindow>(request.Params.ToString());



            FrmVideo frmVideo = this.getVideoFormByID(req.PanelID);

            int screenid = req.ScreenID ?? 0;

            if (screenid > Screen.AllScreens.Length)
            {
                screenid = 0;
            }
            var screen = Screen.AllScreens[screenid];

            frmVideo.Width           = req.Width ?? frmVideo.Width;
            frmVideo.Height          = req.Height ?? frmVideo.Height;
            frmVideo.Location        = new System.Drawing.Point(req.LocationX ?? frmVideo.Location.X, req.LocationY ?? frmVideo.Location.Y);
            frmVideo.TopMost         = req.TopMost ?? true;
            frmVideo.FormBorderStyle = req.ShowWindowBorder == true ? FormBorderStyle.Sizable : FormBorderStyle.None;

            this.VideoManager.SetLayout(req.PanelID, req.LayoutName);

            frmVideo.WindowState = FormWindowState.Normal;
            frmVideo.Show();
        }
        public ActionResult Show(int idComment, int idPost)
        {
            WSRequest request = new WSRequest("/posts/" + idPost + "/comments/" + idComment);

            request.AddAuthorization(Session["token"].ToString());

            var response = request.Get();

            if (response.Code != 200)
            {
                return(RedirectToAction("Index", "Comment", new { message = "Não foi possível exibir o comentário" }));
            }

            var body = response.Body;

            CommentViewModel model = new CommentViewModel
            {
                IdComment  = idComment,
                IdPost     = idPost,
                Content    = body.GetValue("content").ToString(),
                CreatedAt  = body.GetValue("created_at").ToString(),
                ApprovedAt = body.GetValue("approved_at").ToString()
            };

            return(View(model));
        }
        public ActionResult Index()
        {
            var user = (UserViewModel)Session["CurrentUser"];

            if (user != null && user.Permission == 4)
            {
                WSRequest request  = new WSRequest("plans/");
                var       response = request.Get();
                if (response.Code != 200)
                {
                    ModelState.AddModelError("", "Não foi possível buscar esse plano");
                    return(RedirectToAction("Index", "Home", "ERRO"));
                }
                var body = response.Body;
                List <PlanViewModel> list = new List <PlanViewModel>();

                foreach (var item in body.GetValue("plans"))
                {
                    list.Add(
                        new PlanViewModel
                    {
                        IdPlan      = (int)item["id_plan"],
                        Left        = (int)item["left"],
                        Name        = item["name"].ToString(),
                        Price_cents = (int)item["price_cents"],
                        Rewards     = item["rewards"].ToString(),
                        QntTotal    = (int?)item["sold"]
                    }
                        );
                }
                ViewBag.plans = list;
            }
            return(View());
        }
Esempio n. 8
0
        public async Task <ObservableCollection <PedidoSistemaModel> > GetPedido(long nidMesa)
        {
            try
            {
                var sdsUrl = "";

                sdsUrl = "TFServMCOM/f_get_pedido_mesa/" + App.current.EstabSelected.ID_ESTABELECIMENTO + "/" + nidMesa;

                var request = await WSRequest.RequestGET(sdsUrl);

                var json = await request.Content.ReadAsStringAsync();

                json = json.Replace(@"\", "").Replace("\"[", "[").Replace("]\"", "]");
                if (!string.IsNullOrEmpty(json.Replace("\"", "")))
                {
                    return(JsonConvert.DeserializeObject <ObservableCollection <PedidoSistemaModel> >(Util.StringUnicodeToUTF8(json)));
                }
                else
                {
                    return(null);
                }
            }
            catch
            {
                throw;
            }
        }
        public ActionResult Edit(int idUser, int idDevice)
        {
            WSRequest request = new WSRequest("/users/" + idUser + "/devices/" + idDevice);

            request.AddAuthorization(Session["token"].ToString());
            var response = request.Get();

            if (response.Code != 200)
            {
                return(RedirectToAction("Index", "Home", new { message = "Não foi possível buscar o device" }));
            }

            var body = response.Body;

            var model = new DeviceViewModel
            {
                IdDevice        = (int)body["id_device"],
                Alias           = body["alias"].ToString(),
                Color           = body["color"].ToString(),
                FrequencyUpdate = (int)body["frequency_update"],
                IdUser          = (int)body["id_user"]
            };

            return(View(model));
        }
        public JsonResult New(CommentViewModel comment)
        {
            var       user    = (UserViewModel)Session["currentUser"];
            WSRequest request = new WSRequest("posts/" + comment.IdPost.ToString() + "/comments");
            IEnumerable <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("id_user", user.IdUser.ToString()),
                new KeyValuePair <string, string>("id_post", comment.IdPost.ToString()),
                new KeyValuePair <string, string>("content", comment.Content),
            };

            request.AddJsonParameter(parameters);
            request.AddAuthorization(Session["token"].ToString());

            var response = request.Post();
            var data     = new { success = false };

            if (response.Code != 201)
            {
                return new JsonResult()
                       {
                           Data = data
                       }
            }
            ;

            data = new { success = true };
            return(new JsonResult()
            {
                Data = data
            });
        }
        public ActionResult Update(string returnUrl, CommentViewModel comment)
        {
            WSRequest request = new WSRequest("/posts/" + comment.IdPost + "/comments/" + comment.IdComment);

            request.AddAuthorization(Session["token"].ToString());
            IEnumerable <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("content", comment.Content)
            };

            request.AddJsonParameter(parameters);

            var response = request.Put();

            if (response.Code != 204)
            {
                return(RedirectToAction("Edit", "Comment", comment));
            }

            if (returnUrl != null)
            {
                return(Redirect(returnUrl));
            }

            return(RedirectToAction("Show", "Comment", new { idPost = comment.IdPost, idComment = comment.IdComment, message = "O comentário " + comment.IdComment + " foi atualizado" }));
        }
Esempio n. 12
0
        public async Task <ObservableCollection <PedidoSistemaModel> > GetPedidos(string sdsFiltro, DateTime ddtIni, DateTime ddtFim, bool bboFinalizados = false, bool bboFiltro = false)
        {
            try
            {
                var sdsUrl = "";
                if (bboFiltro)
                {
                    var sdtIni = ddtIni.ToString("yyyyMMdd");
                    var sdtFim = ddtFim.AddDays(1).ToString("yyyyMMdd");
                    sdsUrl = "TFServMCOM/f_get_pedidos/" + App.current.EstabSelected.ID_ESTABELECIMENTO + "/" + sdsFiltro + "/" + sdtIni + "/" + sdtFim + "/" + bboFinalizados;
                }
                else
                {
                    sdsUrl = "TFServMCOM/f_get_pedidos/" + App.current.EstabSelected.ID_ESTABELECIMENTO;
                }
                var request = await WSRequest.RequestGET(sdsUrl);

                var json = await request.Content.ReadAsStringAsync();

                json = json.Replace(@"\", "").Replace("\"[", "[").Replace("]\"", "]");
                return(JsonConvert.DeserializeObject <ObservableCollection <PedidoSistemaModel> >(Util.StringUnicodeToUTF8(json)));
            }
            catch
            {
                throw;
            }
        }
        public ActionResult Index(int page = 1)
        {
            WSRequest request  = new WSRequest("posts?page=" + page);
            var       response = request.Get();
            var       model    = new BlogViewModel {
            };

            if (response.Code == 200)
            {
                var body = response.Body;
                model.Posts = new List <PostViewModel>();
                foreach (var post in body.GetValue("posts"))
                {
                    model.Posts.Add(new PostViewModel
                    {
                        IdPost      = (int)post["id_post"],
                        Title       = post["title"].ToString(),
                        Content     = post["content"].ToString(),
                        PublishedAt = post["published_at"].ToString(),
                        IdUser      = (int)post["id_user"],
                        UserName    = post["user_name"].ToString()
                    });
                }
                var pagination = body.GetValue("pagination");
                model.Pagination = new PaginationViewModel
                {
                    NextPage         = (bool)pagination["next_page"],
                    PreviousPage     = (bool)pagination["previous_page"],
                    CurrentPage      = (int)pagination["current_page"],
                    TotalNumberPages = (int)pagination["total_number_pages"],
                };
            }
            return(View(model));
        }
        public ActionResult Delete(int idUser)
        {
            var user = (UserViewModel)Session["CurrentUser"];

            if (user.IdUser != idUser)
            {
                return(RedirectToAction("Show", "Profile"));
            }

            WSRequest request = new WSRequest("/users/" + idUser);

            request.AddAuthorization(Session["token"].ToString());

            var response = request.Delete();

            if (response.Code != 204)
            {
                return(RedirectToAction("Show", "Profile", new { message = "Não foi possivel deletar o usuário" }));
            }

            Session["token"]       = null;
            Session["CurrentUser"] = null;
            var cookie = new HttpCookie("qoala_token");

            cookie.Expires = DateTime.Now.AddDays(-1d);
            Response.Cookies.Add(cookie);

            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult Update(UserViewModel model)
        {
            IEnumerable <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("name", model.Name),
                new KeyValuePair <string, string>("email", model.Email),
                new KeyValuePair <string, string>("permission", model.Permission.ToString()),
                new KeyValuePair <string, string>("address", model.Address),
                new KeyValuePair <string, string>("district", model.District),
                new KeyValuePair <string, string>("city", model.City),
                new KeyValuePair <string, string>("state", model.State),
                new KeyValuePair <string, string>("zipcode", model.ZipCode)
            };

            WSRequest request = new WSRequest("/users/" + model.IdUser);

            request.AddAuthorization(Session["token"].ToString());

            request.AddJsonParameter(parameters);

            var response = request.Put();

            if (response.Code != 204)
            {
                return(RedirectToAction("Edit", "Profile", new { message = "Não foi possivel editar o usuário" }));
            }

            return(RedirectToAction("Show", "Profile", new { message = "Sucesso ao editar perfil" }));
        }
Esempio n. 16
0
        public static bool DoWithRequest(string bookingID)
        {
            try
            {
                using (MOServices client = new MOServices())
                {
                    WSRequest objWSRequest = new WSRequest
                    {
                        DocumentInfo = new DocumentInfo
                        {
                            RequestDate = DateTime.Now.ToString("yyyy-MM-dd"),
                            RequestTime = DateTime.Now.ToString("hh-mm-ss tt"),
                            RequestID   = Guid.NewGuid().ToString(),
                            UserID      = UserName
                        }
                    };
                    MoveToDispatchRequest moveToDispatchRequest = new MoveToDispatchRequest
                    {
                        DocumentNo   = bookingID,
                        DocumentType = "1",
                        enMSGType    = MSGType.ResendETicket
                    };

                    objWSRequest.Request = moveToDispatchRequest;
                    var response = client.ProcessRequest(objWSRequest);
                    return(response.Response.Status == "1");
                }
            }
            catch (Exception exception)
            {
                ErrorLog.WriteErrorLog(exception, bookingID, "MMT_WS_FlightWeather");
                return(false);
            }
        }
Esempio n. 17
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            WSProtocol wsp = new WSProtocol()
            {
                Header = new WSPHeader()
                {
                    BodyType = BodyType.Request, SN = "1", Time = DateTime.Now.ToString(), Ver = "1.0"
                },
            };
            WSRequest request = new WSRequest()
            {
                Command = WSVideoRequest.OpenWindow, Module = WSDefine.VideoModule, RequestSN = "1", Sync = true
            };
            WSVideoRequest_OpenWindow req = new WSVideoRequest_OpenWindow()
            {
                LayoutName       = "16",
                Height           = 600,
                Width            = 800,
                LocationX        = 0,
                LocationY        = 0,
                PanelID          = "1",
                ScreenID         = 0,
                ShowVCTitle      = true,
                ShowWindowBorder = true,
                TopMost          = true
            };

            request.Params = req;

            wsp.Body = request;
            this.ricktextbox.AppendText($"{JsonConvert.SerializeObject(wsp)}\n");
        }
Esempio n. 18
0
        public ActionResult Edit(int idUser)
        {
            WSRequest request = new WSRequest("users/" + idUser);

            request.AddAuthorization(Session["token"].ToString());

            var response = request.Get();

            if (response.Code != 200)
            {
                return(RedirectToAction("Index", "User"));
            }

            var body = response.Body;

            var model = new UserViewModel
            {
                IdUser     = (int)body["id_user"],
                Name       = body["name"].ToString(),
                Email      = body["email"].ToString(),
                Permission = (int)body["permission"],
                Address    = body["address"].ToString(),
                District   = body["district"].ToString(),
                City       = body["city"].ToString(),
                State      = body["state"].ToString(),
                ZipCode    = body["zipcode"].ToString(),
            };

            return(View(model));
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var token = HttpContext.Current.Session["token"];

            if (token == null)
            {
                filterContext.Result = new RedirectToRouteResult(routeValuesRedirect());
                return;
            }

            WSRequest request = new WSRequest("accounts/me");

            request.AddAuthorization(token.ToString());

            var response = request.Get();

            if (response.Code != 200)
            {
                filterContext.Result = new RedirectToRouteResult(routeValuesRedirect());
                return;
            }
            var body = response.Body;

            Models.ViewModels.UserViewModel user = new Models.ViewModels.UserViewModel
            {
                IdUser     = (int)body.GetValue("id_user"),
                Email      = body.GetValue("email").ToString(),
                Name       = body.GetValue("name").ToString(),
                IdPlan     = (int?)body.GetValue("id_plan"),
                Permission = (int)body.GetValue("permission")
            };

            HttpContext.Current.Session["CurrentUser"] = user;
        }
Esempio n. 20
0
        public ActionResult Update(UserViewModel model)
        {
            WSRequest request = new WSRequest("/users/" + model.IdUser);

            request.AddAuthorization(Session["token"].ToString());
            IEnumerable <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("name", model.Name),
                new KeyValuePair <string, string>("email", model.Email),
                new KeyValuePair <string, string>("permission", model.Permission.ToString()),
                new KeyValuePair <string, string>("address", model.Address),
                new KeyValuePair <string, string>("district", model.District),
                new KeyValuePair <string, string>("city", model.City),
                new KeyValuePair <string, string>("state", model.State),
                new KeyValuePair <string, string>("zipcode", model.ZipCode),
            };

            request.AddJsonParameter(parameters);

            var response = request.Put();

            if (response.Code != 204)
            {
                return(RedirectToAction("Edit", "User", model));
            }

            return(RedirectToAction("Index", "User"));
        }
Esempio n. 21
0
        public ActionResult Logout()
        {
            WSRequest request = new WSRequest("accounts/logout");

            IEnumerable <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("token", Session["token"].ToString())
            };

            request.AddAuthorization(Session["token"].ToString());
            request.AddJsonParameter(parameters);

            try
            {
                var response = request.Post();
                if (response.Code != 200)
                {
                    return(RedirectToAction("Index", "Home", new { Message = "Não foi possível delogar" }));
                }
                Session["token"]       = null;
                Session["CurrentUser"] = null;
                var cookie = new HttpCookie("qoala_token");
                cookie.Expires = DateTime.Now.AddDays(-1d);
                Response.Cookies.Add(cookie);
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Home", new { Message = e.Message }));
            }

            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 22
0
        /// <summary>
        /// Websocket命令请求处理
        /// </summary>
        /// <param name="request"></param>
        public void WSRequestProc(WSRequest request)
        {
            switch (request.Command)
            {
            case WSVideoRequest.OpenWindow:
                this.procVideo_OpenWindow(request);
                break;

            case WSVideoRequest.CloseWindow:
                break;

            case WSVideoRequest.StartPreview:
                this.procVideo_StartPreview(request);
                break;

            case WSVideoRequest.StopPreview:
                break;

            case WSVideoRequest.StartPlayback:
                this.procVideo_StartPlayback(request);
                break;

            case WSVideoRequest.StopPlayback:
                break;

            default:
                this.LogModule.Error($"不支持的视频指令: {request.Command}");
                break;
            }
        }
Esempio n. 23
0
        private void procVideo_StartPlayback(WSRequest request)
        {
            var req = JsonConvert.DeserializeObject <WSVideoRequest_StartPlayback>(request.Params.ToString());

            VideoSourceInfo videoSourceInfo = new VideoSourceInfo()
            {
                ID       = req.SourceID,
                IP       = req.SourceIP,
                Port     = req.SourcePort,
                User     = req.SourceUser,
                Password = req.SourcePassword,
                Type     = (VideoSourceType)req.SourceType,
                Name     = req.SourceName
            };

            CameraInfo cameraInfo = new CameraInfo()
            {
                ID         = req.CameraID,
                CameraCode = req.CameraCode,
                Name       = req.CameraName
            };

            VideoControl vc = this.VideoManager.GetVideoControl(req.PanelID, req.VCIndex);

            if (vc == null)
            {
                this.LogModule.Error("找不到指定控件");
                return;
            }
            this.VideoManager.StartPlayback(cameraInfo, videoSourceInfo, vc, req.StartTime, req.EndTime);
        }
Esempio n. 24
0
 public async Task SalvarFamilia(long nid, string descri)
 {
     try {
         await(await WSRequest.RequestGET("TFServMMAT/f_salvar_familia/" + App.current.EstabSelected.ID_ESTABELECIMENTO + "/" + nid + "/" + descri)).Content.ReadAsStringAsync();
     }
     catch
     {
     }
 }
Esempio n. 25
0
        private void procVideo_CloseWindow(WSRequest request)
        {
            var req = JsonConvert.DeserializeObject <WSVideoRequest>(request.Params.ToString());


            FrmVideo frmVideo = this.getVideoFormByID(req.PanelID);

            frmVideo.Hide();
        }
Esempio n. 26
0
        internal static void wsInitUpdateInterface(EntityInitRawMaterial q)
        {
            String connectionString = "ConnectToInterfaceDESA";
            string queryString      = @"UPDATE [Traza_material].[dbo].[XXE_WMS_COGISCAN_PEDIDO_LPNS]SET [STATUS] = 'DONE' WHERE LPN = '" + q.Num_Pallet + "'";

            SQLMapper.Conectivity.ConnectItAndBringResults(queryString, connectionString);

            { SQLDataManager.IAServerInsertionLog(q, WSRequest.InitRawMaterial(q)); }
        }
Esempio n. 27
0
        private void refreshbalance()
        {
            string req = WSRequest.getRequest("account_info", "Balance", JsonRequest.getAccountInfoJsonRequest(RConfig.rippleAddress));

            wsClient.Send(req);

            req = WSRequest.getRequest("account_lines", "Balance", JsonRequest.getAccountLinesJsonRequest(RConfig.rippleAddress));
            wsClient.Send(req);
        }
        public virtual void Send <I, O>(string service, string method, I payload, ClientTransportCallback <O> callback, C ctx)
        {
            try {
                if (!Ready)
                {
                    throw new Exception("WebSocketTransport is not ready.");
                }

                var req = new WebSocketRequestMessageJson(WebSocketMessageKind.RpcRequest);
                req.ID      = GetRandomMessageId();
                req.Service = service;
                req.Method  = method;
                req.Data    = _marshaller.Marshal(payload);

                var record = new WSRequest();
                _requests.Add(req.ID, record);
                record.Timer   = new Timer();
                record.Success = msg => {
                    O data;
                    try {
                        data = _marshaller.Unmarshal <O>(msg.Data);
                    }
                    catch (Exception ex) {
                        callback.Failure(new TransportMarshallingException("Unexpected exception occured during unmarshalling.", ex));
                        return;
                    }
                    callback.Success(data);
                };

                record.Failure = (ex) => {
                    callback.Failure(new TransportException("Request failed. ", ex));
                };
                record.Timer.Interval = DefaultTimeoutInterval * 1000;
                record.Timer.Elapsed += (sender, e) => {
                    HandleRPCFailure(req.ID, new Exception("Request timed out."));
                };

                var serialized = _marshaller.Marshal(req);
                _logger.Logf(LogLevel.Trace, "WebSocketTransport: Outgoing message: \n{0}", serialized);

                _ws.SendAsync(serialized, success => {
                    if (success)
                    {
                        return;
                    }
                    HandleRPCFailure(req.ID, new Exception("Sending request failed."));
                });
                record.Timer.Start();
            }
            catch (Exception ex)
            {
                callback.Failure(
                    new TransportException("Unexpected exception occured during async request.", ex)
                    );
            }
        }
Esempio n. 29
0
 public async Task SalvarMovimEstoque(long nidMater, long nidTpMovim, double nvlMovim, double nqtMovim, string sdsHistorico)
 {
     try
     {
         await(await WSRequest.RequestGET("TFServMMAT/f_movim_estoque_manual_app/" + App.current.EstabSelected.ID_ESTABELECIMENTO + "/" + nidMater + "/" + nidTpMovim + "/" + nvlMovim.ToString().Replace(".", "").Replace(",", ".") + "/" + nqtMovim.ToString().Replace(".", "").Replace(",", ".") + "/" + sdsHistorico)).Content.ReadAsStringAsync();
     }
     catch
     {
     }
 }
Esempio n. 30
0
        public ActionResult RegisterSponsor(RegisterViewModel model)
        {
            WSRequest request = new WSRequest("accounts/register");

            IEnumerable <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("name", model.Name),
                new KeyValuePair <string, string>("password", model.Password),
                new KeyValuePair <string, string>("document", model.Document),
                new KeyValuePair <string, string>("permission", "4"),
                new KeyValuePair <string, string>("email", model.Email)
            };

            request.AddJsonParameter(parameters);
            var data = new
            {
                message = "Registro efetuado com sucesso"
            };

            try
            {
                var response = request.Post();
                if (response.Code != 201)
                {
                    Response.StatusCode = 400;
                    data = new
                    {
                        message = response.Body.GetValue("Message").ToString()
                    };
                }
                else
                {
                    string token = response.Body.GetValue("token").ToString();
                    Session["token"] = token;
                    var cookie = new HttpCookie("qoala_token", token);
                    cookie.Expires = DateTime.Now.AddDays(7);
                    Response.Cookies.Add(cookie);
                }
            }
            catch (Exception e)
            {
                Response.StatusCode = 400;
                data = new
                {
                    message = e.Message
                };
            }

            return(new JsonResult()
            {
                Data = data
            });
        }