public string EventAction(ActionModel model) { string value = ""; using (var db = new UnseentalentdbDataContext()) { Event events = db.Events.FirstOrDefault(t => t.Id == Convert.ToInt64(model.ID)); if (events != null) { switch (model.Type) { case ActionType.Delete: events.IsDeleted = true; value = "1"; break; case ActionType.Block: events.IsActive = false; value = "2"; break; case ActionType.UnBlock: events.IsActive = true; value = "3"; break; default: break; } db.SubmitChanges(); } else { value = "0"; } return value; } }
public void InsertAction(ActionModel sentAction) { SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@USERID", sentAction.UserId), new SqlParameter("@ACTION", sentAction.Action), new SqlParameter("@VALUE", sentAction.Value), }; ExecuteSPNonReturnData("InsertAction", parameters); }
public void Post(ActionModel sentAction) { new ActionModel().PostAction(sentAction); }
protected virtual string NormalizeUrlActionName(string rootPath, string controllerName, ActionModel action, string httpMethod, [CanBeNull] ConventionalControllerSetting configuration) { var actionNameInUrl = HttpMethodHelper .RemoveHttpMethodPrefix(action.ActionName, httpMethod) .RemovePostFix("Async"); if (configuration?.UrlActionNameNormalizer == null) { return(actionNameInUrl); } return(configuration.UrlActionNameNormalizer( new UrlActionNameNormalizerContext( rootPath, controllerName, action, actionNameInUrl, httpMethod ) )); }
/// <inheritdoc /> public virtual bool AppliesToAction(ODataControllerActionContext context) { if (context == null) { throw Error.ArgumentNull(nameof(context)); } // Be noted, the validation checks (non OData controller, non OData action) are done before calling this method. ControllerModel controllerModel = context.Controller; ActionModel actionModel = context.Action; bool isODataController = controllerModel.Attributes.Any(a => a is ODataRoutingAttribute); bool isODataAction = actionModel.Attributes.Any(a => a is ODataRoutingAttribute); // At least one of controller or action has "ODataRoutingAttribute" // The best way is to derive your controller from ODataController. if (!isODataController && !isODataAction) { return(false); } // TODO: Which one is better? input from context or inject from constructor? IEnumerable <string> prefixes = context.Options.Models.Keys; // Loop through all attribute routes defined on the controller. var controllerSelectors = controllerModel.Selectors.Where(sm => sm.AttributeRouteModel != null).ToList(); if (controllerSelectors.Count == 0) { // If no controller route template, we still need to go through action to process the action route template. controllerSelectors.Add(null); } // In order to avoiding pollute the action selectors, we use a Dictionary to save the intermediate results. IDictionary <SelectorModel, IList <SelectorModel> > updatedSelectors = new Dictionary <SelectorModel, IList <SelectorModel> >(); foreach (var actionSelector in actionModel.Selectors) { if (actionSelector.AttributeRouteModel != null && actionSelector.AttributeRouteModel.IsAbsoluteTemplate) { ProcessAttributeModel(actionSelector.AttributeRouteModel, prefixes, context, actionSelector, actionModel, controllerModel, updatedSelectors); } else { foreach (var controllerSelector in controllerSelectors) { var combinedRouteModel = AttributeRouteModel.CombineAttributeRouteModel(controllerSelector?.AttributeRouteModel, actionSelector.AttributeRouteModel); ProcessAttributeModel(combinedRouteModel, prefixes, context, actionSelector, actionModel, controllerModel, updatedSelectors); } } } // remove the old one. foreach (var selector in updatedSelectors) { actionModel.Selectors.Remove(selector.Key); } // add new one. foreach (var selector in updatedSelectors) { foreach (var newSelector in selector.Value) { actionModel.Selectors.Add(newSelector); } } // let's just return false to let this action go to other conventions. return(false); }
public Response<string> EventAction(ActionModel model) { var response = new Response<string>(); string value = ""; var obj = new UnseenTalentsMethod(); value = obj.EventAction(model); if (value == "1") { response.Create(true, 0, Messages.delete, value); } else if (value == "2") { response.Create(true, 0, Messages.block, value); } else if (value == "3") { response.Create(true, 0, Messages.unBlock, value); } else { response.Create(false, 0, Messages.INVALID_REQ, value); } return response; }
//TODO: Hey my change has been deleted and something blinking left side!!! /// <summary> /// Initializes a new instance of the <see cref="ActionViewModel"/> class. /// </summary> public ActionViewModel(ActionModel action) { this.Action = action; }
private static string SerializeRecursive(ResearchNode node, string text, ApplicationDbContext db, ActionModel model) { text += "<tr>"; text += "<td>" + node.Name + "</td>"; string pre = ""; node.GetPrerequisiteNodes(db).ToList().ForEach(n => pre += n.Name + ", "); text += "<td>" + pre + "</td>"; string nextNodes = ""; node.GetNextNodes(db).ToList().ForEach(n => nextNodes += n.Name + ", "); text += "<td>" + nextNodes + "</td>"; text += "<td>" + node.RDCost + "</td>"; text += "<td>" + node.CashCost + "</td>"; var activeNodes = db.ActiveResearchNodes.Where(arn => arn.Corporation.Id == model.Corporation.Id).Select(n => n.ResearchNode.Name).ToList(); if (model.DataCache.LearnedResearchNodes.Select(n => n.Name).Contains(node.Name)) { text += "<td><button disabled class='btn btn-default'>Learned</button></td>"; } else if (activeNodes.Contains(node.Name)) { text += "<td><button class='btn btn-default' data-toggle='button' type='button' onclick='addSingleAction("" + ActionService.GetActionStringForView(Constants.Constants.ActionTypeResearch, "Action="+Constants.Constants.CancelActiveResearch + ":" + node.Name, Constants.Constants.Empty) + @";", this)'>Cancel</button></td>"; } else { var cashEnabledText = model.DataCache.Corporation.Cash >= node.CashCost && node.Enabled ? "enabled" : "disabled"; text += @"<td><button " + cashEnabledText + " class='btn btn-default' type='button' data-toggle='button' onclick='addSingleAction("" + ActionService.GetActionStringForView(Constants.Constants.ActionTypeResearch, node.Script, Constants.Constants.LearnByCash) + @";", this)'>Cash ("+node.CashCost+")</button>"; var researchEnabledText = node.Enabled ? "enabled" : "disabled"; ; text += @"<button " + researchEnabledText + " data-toggle='button' class='btn btn-default' type='button' onclick='addSingleAction("" + ActionService.GetActionStringForView(Constants.Constants.ActionTypeResearch, node.Script, Constants.Constants.SetActiveResearch) + @";", this)'>Set Active Research (" + node.GetTurnsToResearch(model.Corporation.RD) + ")</button></td>"; } text += "</tr>"; if (node.GetNextNodes(db).Any()) node.GetNextNodes(db).ToList().ForEach(n => text = SerializeRecursive(n, text, db, model)); return text; }
protected virtual void ConfigureSelector(string rootPath, string controllerName, ActionModel action, [CanBeNull] ConventionalControllerSetting configuration) { RemoveEmptySelectors(action.Selectors); var remoteServiceAtt = ReflectionHelper.GetSingleAttributeOrDefault <RemoteServiceAttribute> (action.ActionMethod); if (remoteServiceAtt != null && !remoteServiceAtt.IsEnabledFor(action.ActionMethod)) { return; } if (!action.Selectors.Any()) { AddRocketServiceSelector(rootPath, controllerName, action, configuration); } else { NormalizeSelectorRoutes(rootPath, controllerName, action, configuration); } }
public ActionScheduler() { this.RequiresAuthentication(); Get("/actionscheduler", args => View["ActionScheduler", new ActionSchedulerModel()]); Post("/actionscheduler", args => { var body = new StreamReader(Request.Body).ReadToEnd(); body = HttpUtility.UrlDecode(body); var parameters = HttpUtility.ParseQueryString(body); if (parameters["action"]?.Equals("delete") == true) { var id = int.Parse(parameters["id"]); FUTSettings.Instance.ActionScheduler.RemoveAll(x => x.ID == id); FUTSettings.Instance.SaveChanges(); Fifa.ActionScheduler.ActionScheduler.CreateScheduler(); } else if (parameters["action"]?.Equals("import") == true) { FUTSettings.Instance.ActionScheduler = new List <ActionModel>(); try { if (!String.IsNullOrEmpty(parameters["actions"])) { var data = JsonConvert.DeserializeObject <List <ActionModel> >(parameters["actions"]); FUTSettings.Instance.ActionScheduler = data; FUTSettings.Instance.SaveChanges(); Fifa.ActionScheduler.ActionScheduler.CreateScheduler(); } } catch (Exception e) { } } else { var type = int.Parse(parameters["type"]); var time = TimeSpan.Parse(parameters["time"]); var percent = int.Parse(parameters["percent"]); var lastId = new ActionModel() { ID = 0, Type = ActionType.None, Time = TimeSpan.Zero }; if (FUTSettings.Instance.ActionScheduler != null) { lastId = FUTSettings.Instance.ActionScheduler.LastOrDefault(); } var id = lastId?.ID + 1 ?? 0; if (FUTSettings.Instance.ActionScheduler == null) { FUTSettings.Instance.ActionScheduler = new List <ActionModel>(); } var model = new ActionModel() { ID = id, Type = (ActionType)type, Time = time, Description = Enum.GetName(typeof(ActionType), (ActionType)type) }; if (model.Type == ActionType.SetBuyPercent || model.Type == ActionType.SetSellPercent) { model.Percent = percent; model.Description += $" ({percent})"; } FUTSettings.Instance.ActionScheduler.Add(model); FUTSettings.Instance.SaveChanges(); Fifa.ActionScheduler.ActionScheduler.CreateScheduler(); } return(Response.AsRedirect("/actionscheduler")); }); }
private static void ExtractParameterDetails(ActionModel action) { var requestParameter = action.Parameters.FirstOrDefault( z => z.ParameterInfo.ParameterType.GetInterfaces().Any( i => i.IsGenericType && (typeof(IRequest <>) == i.GetGenericTypeDefinition() || typeof(IStreamRequest <>) == i.GetGenericTypeDefinition()) ) ) ; if (requestParameter is null) { return; } // Likely hit the generator, no point running from here if (requestParameter.Attributes.Count(z => z is BindAttribute or CustomizeValidatorAttribute) == 2) { _propertiesToHideFromOpenApi.TryAdd( requestParameter.ParameterType, requestParameter.ParameterType.GetProperties().Select(z => z.Name).Except( requestParameter.Attributes.OfType <BindAttribute>().SelectMany(z => z.Include) ).ToArray() ); return; } var index = action.Parameters.IndexOf(requestParameter); var newAttributes = requestParameter.Attributes.ToList(); var otherParams = action.Parameters .Except(new[] { requestParameter }) .Select(z => z.ParameterName) .ToArray(); var propertyAndFieldNames = requestParameter.ParameterType .GetProperties() .Select(z => z.Name) .ToArray(); var bindNames = propertyAndFieldNames .Except(otherParams, StringComparer.OrdinalIgnoreCase) .ToArray(); if (propertyAndFieldNames.Length != bindNames.Length) { var ignoreBindings = propertyAndFieldNames.Except(bindNames, StringComparer.OrdinalIgnoreCase).ToArray(); newAttributes.Add(new BindAttribute(bindNames)); action.Properties.Add( typeof(CustomizeValidatorAttribute), bindNames ); _propertiesToHideFromOpenApi.TryAdd(requestParameter.ParameterType, ignoreBindings); var model = action.Parameters[index] = new ParameterModel(requestParameter.ParameterInfo, newAttributes) { Action = requestParameter.Action, BindingInfo = requestParameter.BindingInfo, ParameterName = requestParameter.ParameterName }; foreach (var item in requestParameter.Properties) { model.Properties.Add(item); } } }
public void Apply(ActionModel action) { }
public ActionModel BeginWork(SNSession session, T_FLOW beginFlow, T_STEP beginStep, decimal prevWorkAnyNodeId = 0) { #region 创建事项流程简述 //TODO:自动生成 // 1.确定事项的入口:确定入口步骤 done // 2.1.根据入口步骤生曾第一节点(即产生了主线路) done // 2.2.根据第一节点产生事项 done // 2.3.生成节点授权信息(steptouser) done // 3.根据入口步骤所属的流程,生成相关阶段 done // 4.1.创建表单--根据步骤ID获取要默认创建的文笺列表 done // 4.2.默认打开排序号第一的表单 todo // 4.3.获取可输入项--根据文笺ID获取当前步骤文笺的输入项列表 done //----------------- //TODO:输入数据 // 1.1.输入事项相关属性,生成事项标签 // 2.1.输入项输入值 // 3.1.设置表单属性(序号、是否带纸质等) //----------------- //TODO:完成,保存数据 // 1.1.保存节点 // 1.2.保存节点授权 // 2.1.保存表单 // 2.2.保存输入项 // 3.1.保存阶段 // 4.1.保存事项 //----------------- //TODO:保存下步信息(事项第一步不可接新流程) // 1.1.产生下步节点 // 1.2.产生下步授权(stepToUser) //throw new NotImplementedException(); #endregion // 构建控制工厂 var fact = new CtrlFactory(); // 构建动作ActionModel var vm = new ActionModel(); // 生成节点新ID var nodeId = this.BuildID(); // 生成事项第一节点 var nodeCtrl = fact.NodeCtrl(); vm.CurrentNode = nodeCtrl.BuildTo(beginStep.STEP_ID, beginStep.STEP_NAME, nodeId, prevWorkAnyNodeId); // 生成事项第一节点域 vm.CurrentNodeDomain = nodeCtrl.CreateNodeDomain(vm.CurrentNode.NODE_ID, session.DeptId, session.UserId, session.DelegateUserId); // 生成事项 var workCtrl = fact.WorkCtrl(); vm.CurrentWork = workCtrl.CreateWork(vm.CurrentNode.NODE_ID, session.OrgId); // 生成第一阶段 var stageCtrl = fact.StageCtrl(); vm.CurrentStage = stageCtrl.CreateStage(vm.CurrentNode.NODE_ID, beginStep.FLOW_ID, beginFlow.FLOW_NAME); // 生成需自动创建的实体文笺 var entityCtrl = fact.EntityCtrl(); vm.EntityList = entityCtrl.CreateEntityForNode(vm.CurrentNode.STEP_ID, vm.CurrentWork.WORK_ID, vm.CurrentNode.NODE_ID, vm.CurrentNodeDomain.DEPT_ID, vm.CurrentNodeDomain.USER_ID); //TODO:验证AM下各个对象的完备性 return vm; }
public decimal QuickSave(ActionModel vm) { // 保存节点 // 保存节点域 // 保存事项 // 保存阶段 // 保存实体 // 保存实体项 // TODO:保存附件(上传附件) // nextnode using (var scope = new TransactionScope()) //分布式事务 { var re = 0; using (var ctx = new OAContext()) { #region 保存节点 var fact = new CtrlFactory(); var nodeCtrl = fact.NodeCtrl(); nodeCtrl.SaveNode(vm.CurrentNode); #endregion #region 保存节点域 nodeCtrl.SaveNodeDomain(vm.CurrentNodeDomain); #endregion #region 保存事项 //TODO:检查work的完备性,必须有事项名、事项类型、{事项编号}、紧急程度、所属单位 fact.WorkCtrl().SaveWork(vm.CurrentWork); #endregion #region 保存阶段 fact.StageCtrl().SaveStage(vm.CurrentStage); #endregion #region 保存实体列表 var entityCtrl = fact.EntityCtrl(); entityCtrl.SaveEntities(vm.EntityList, EntityTag.Active.QuickSave); #endregion #region 保存实体项列表 entityCtrl.SaveEntityItems(vm.EntityItemList, EntityItemTag.Active.QuickSave); #endregion #region 保存附件列表 #endregion re = ctx.SaveChanges(); } scope.Complete(); //提交事务 return re; } }
public static ResearchTree BuildTreeForView(ActionModel model, ApplicationDbContext db) { var nodes = db.ResearchNodes.Where(x => true).ToList(); var learnedNodes = db.LearnedResearchNodes.Where(lrn => model.Corporation.Id == lrn.Corporation.Id).Include(n => n.ResearchNode).Select(n=>n.ResearchNode.Name).ToList(); var activeNodes = db.ActiveResearchNodes.Where(arn => arn.Corporation.Id == model.Corporation.Id).Select(n => n.ResearchNode.Name).ToList(); var t = new ResearchTree { Name = "Rocketry", StartingNode = nodes.FirstOrDefault(n => n.Name == "Basic Rocketry") }; nodes.ForEach( node => node.Enabled = !learnedNodes.Contains(node.Name) && !activeNodes.Contains(node.Name)//Not actively being researched or already researched && node.PrereqsMet(db, model.DataCache.LearnedResearchNodes)); //has prereqs met or has none return t; }
public static string GetTreeBody(ResearchTree tree, ApplicationDbContext db, ActionModel model) { var text = ""; text = SerializeRecursive(tree.StartingNode, text, db, model); return text; }
protected virtual void AddRocketServiceSelector(string rootPath, string controllerName, ActionModel action, [CanBeNull] ConventionalControllerSetting configuration) { var httpMethod = SelectHttpMethod(action, configuration); var rocketServiceSelectorModel = new SelectorModel { AttributeRouteModel = CreateRocketServiceAttributeRouteModel(rootPath, controllerName, action, httpMethod, configuration), ActionConstraints = { new HttpMethodActionConstraint(new [] { httpMethod }) } }; action.Selectors.Add(rocketServiceSelectorModel); }
/// <summary> /// Method to invoke when the EditAction command is executed. /// </summary> private void OnEditActionExecute(ActionModel Action) { if (Action == null) return; Debug.WriteLine("Received Action"); var typeFactory = this.GetTypeFactory(); dynamic actionViewModel; var index = SelectedIndex; switch (Action.ActionType) { case ActionType.Start: //TODO: Make statusbar animation break; case ActionType.KeyPress: actionViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion<KeyPressWindowViewModel>(Action); if (uiVisualizerService.ShowDialog(actionViewModel) ?? false) { this.Actions[index] = actionViewModel.KeyPress; //? 잠시 깜빡이면서 다시 선택이 되는 느낌이 드는데, 그런 현상을 막을 방법은 없을까? this.SelectedIndex = index; } break; case ActionType.MousePress: break; case ActionType.Delay: break; case ActionType.Jump: break; case ActionType.Text: break; case ActionType.Call: break; case ActionType.Lock: break; case ActionType.Repeat: break; default: break; } this.Macro[index].RaiseAllPropertiesChanged(); }
protected virtual string SelectHttpMethod(ActionModel action, ConventionalControllerSetting configuration) { return(HttpMethodHelper.GetConventionalVerbForMethodName(action.ActionName)); }
async void NextButtonTapRecognizer_Tapped(object sender, System.EventArgs e) { User user = null; try { user = App.Settings.GetUser(); } catch (Exception ex) { } IProgressBar progress = DependencyService.Get<IProgressBar>(); try { if (string.IsNullOrWhiteSpace(eventDescription.Text) || string.IsNullOrWhiteSpace(eventTitle.Text)) { await DisplayAlert(Constants.ALERT_TITLE, "Value cannot be empty", Constants.ALERT_OK); } else { string input = pageTitle; CustomListViewItem item = new CustomListViewItem { Name = eventDescription.Text }; bool serviceResultOK = false; if (input == Constants.ADD_ACTIONS || input == Constants.EDIT_ACTIONS) { #region ADD || EDIT ACTIONS try { GoalDetails newGoal = new GoalDetails(); ActionModel details = new ActionModel(); if (!isUpdatePage) { progress.ShowProgressbar("Creating new action.."); } else { progress.ShowProgressbar("Updating the action.."); details.action_id = currentGemId; } details.action_title = eventTitle.Text; details.action_details = eventDescription.Text; details.user_id = user.UserId; details.location_latitude = lattitude; details.location_longitude = longitude; if(!string.IsNullOrEmpty(currentAddress)) { details.location_address = currentAddress; } //details.start_date = DateTime.Now.ToString("yyyy/MM/dd"); // for testing only //details.end_date = DateTime.Now.AddDays(1).ToString("yyyy/MM/dd"); // for testing only //details.start_time = DateTime.Now.AddHours(1).ToString("HH:mm"); //for testing only //details.end_time = DateTime.Now.AddHours(2).ToString("HH:mm"); //for testing only if (!string.IsNullOrEmpty(App.SelectedActionStartDate)) { DateTime myDate = DateTime.Now;//DateTime.ParseExact("2009-05-08 14:40:52,531", "yyyy-MM-dd HH:mm:ss,fff", System.Globalization.CultureInfo.InvariantCulture); myDate = DateTime.Parse(App.SelectedActionStartDate); details.start_date = App.SelectedActionStartDate; details.end_date = App.SelectedActionEndDate; details.start_time = myDate.ToString("HH:mm"); myDate = DateTime.Parse(App.SelectedActionEndDate); details.end_time = myDate.ToString("HH:mm"); details.action_repeat = "0"; details.action_alert = App.SelectedActionReminderValue.ToString(); } if (!string.IsNullOrEmpty(currentAddress)) { details.location_address = currentAddress; } if (!await ServiceHelper.AddAction(details)) { await DisplayAlert(Constants.ALERT_TITLE, Constants.NETWORK_ERROR_MSG, Constants.ALERT_OK); } else { try { var suportingActions = await ServiceHelper.GetAllSpportingActions(); //for testing only if (suportingActions != null) { App.actionsListSource = null; App.actionsListSource = new List<CustomListViewItem>(); foreach (var action in suportingActions) { App.actionsListSource.Add(action); } } CustomListViewItem newEmotionItem = new CustomListViewItem(); newEmotionItem.EventID = App.actionsListSource.First().EventID; newEmotionItem.Name = App.actionsListSource.First().Name; newEmotionItem.SliderValue = App.actionsListSource.First().SliderValue; newEmotionItem.Source = Device.OnPlatform("tick_box.png", "tick_box.png", "//Assets//tick_box.png"); SelectedItemChangedEventArgs newEmotionEvent = new SelectedItemChangedEventArgs( newEmotionItem ); feelingSecondPage.OnActionPickerItemSelected( this, newEmotionEvent ); serviceResultOK = true; } catch (System.Exception) { DisplayAlert(Constants.ALERT_TITLE, "Error in retrieving goals list, Please try again", Constants.ALERT_OK); } } // ILocalNotification notfiy = DependencyService.Get<ILocalNotification>(); // if (!isUpdatePage) // { // notfiy.ShowNotification("Purpose Color - Action Created", "", eventTitle.Text, false); // } // else // { // notfiy.ShowNotification("Purpose Color - Action Updated","", eventTitle.Text, false); // } } catch (Exception ex) { var test = ex.Message; } progress.HideProgressbar(); #endregion } else if (input == Constants.ADD_EVENTS || input == Constants.EDIT_EVENTS) { #region ADD || EDIT EVENTS try { EventDetails details = new EventDetails(); details.event_title = eventTitle.Text; details.event_details = eventDescription.Text; details.user_id = user.UserId; details.location_latitude = lattitude; details.location_longitude = longitude; if (!string.IsNullOrEmpty(currentAddress)) { details.location_address = currentAddress; } if (!isUpdatePage) { progress.ShowProgressbar("Creating new event.."); } else { progress.ShowProgressbar("Updating the event.."); details.event_id = currentGemId; } if (!await ServiceHelper.AddEvent(details)) { await DisplayAlert(Constants.ALERT_TITLE, Constants.NETWORK_ERROR_MSG, Constants.ALERT_OK); } else { await FeelingNowPage.DownloadAllEvents(); serviceResultOK = true; CustomListViewItem newEmotionItem = new CustomListViewItem(); newEmotionItem.EventID = App.eventsListSource.First().EventID; newEmotionItem.Name = App.eventsListSource.First().Name; newEmotionItem.SliderValue = App.eventsListSource.First().SliderValue; SelectedItemChangedEventArgs newEmotionEvent = new SelectedItemChangedEventArgs( newEmotionItem ); feelingsPage.OnEventPickerItemSelected( this, newEmotionEvent ); // if(!isUpdatePage) // { // await Navigation.PopModalAsync(); // } // else { // await Navigation.PopModalAsync(); // } } } catch (Exception ex) { var test = ex.Message; } progress.HideProgressbar(); #endregion } else if (input == Constants.ADD_GOALS || input == Constants.EDIT_GOALS) { #region ADD || EDIT GOALS try { GoalDetails newGoal = new GoalDetails(); //EventDetails newGoal = new EventDetails(); newGoal.goal_title = eventTitle.Text; newGoal.goal_details = eventDescription.Text; newGoal.user_id = user.UserId; newGoal.location_latitude = lattitude; newGoal.location_longitude = longitude; newGoal.category_id = "1"; if (!string.IsNullOrEmpty(App.SelectedActionStartDate)) { newGoal.start_date = App.SelectedActionStartDate; //DateTime.Now.ToString("yyyy/MM/dd"); // for testing only newGoal.end_date = App.SelectedActionEndDate; //DateTime.Now.AddDays(1).ToString("yyyy/MM/dd"); // for testing onl } if (!string.IsNullOrEmpty(currentAddress)) { newGoal.location_address = currentAddress; } if (!isUpdatePage) { progress.ShowProgressbar("Creating new goal.."); } else { progress.ShowProgressbar("Updating the goal.."); newGoal.goal_id = currentGemId; } if (!await ServiceHelper.AddGoal(newGoal)) { await DisplayAlert(Constants.ALERT_TITLE, Constants.NETWORK_ERROR_MSG, Constants.ALERT_OK); } else { try { var goals = await ServiceHelper.GetAllGoals( user.UserId ); if (goals != null) { App.goalsListSource = null; App.goalsListSource = new List<CustomListViewItem>(); foreach (var goal in goals) { App.goalsListSource.Add(goal); } } CustomListViewItem newEmotionItem = new CustomListViewItem(); newEmotionItem.EventID = App.goalsListSource.First().EventID; newEmotionItem.Name = App.goalsListSource.First().Name; newEmotionItem.SliderValue = App.goalsListSource.First().SliderValue; SelectedItemChangedEventArgs newGoalsEvent = new SelectedItemChangedEventArgs( newEmotionItem ); feelingSecondPage.OnGoalsPickerItemSelected( this, newGoalsEvent ); serviceResultOK = true; } catch (System.Exception) { DisplayAlert(Constants.ALERT_TITLE, "Error in retrieving goals list, Please try again", Constants.ALERT_OK); } } } catch (Exception ex) { DisplayAlert(Constants.ALERT_TITLE, ex.Message, Constants.ALERT_OK); } progress.HideProgressbar(); #endregion } if (serviceResultOK) { if (!isUpdatePage) { await Navigation.PopAsync(); } else { if(Device.OS != TargetPlatform.iOS) { await Navigation.PopToRootAsync(); } else { await Navigation.PopToRootAsync(); } #region MyRegionNavigate back to GEM details page //progress.ShowProgressbar("Loading"); // // if (App.isEmotionsListing) { // try { // SelectedEventDetails eventDetails = await ServiceHelper.GetSelectedEventDetails(currentGemId); // if (eventDetails != null) // { // List<string> listToDownload = new List<string>(); // // foreach (var eventi in eventDetails.event_media) // { // if(string.IsNullOrEmpty(eventi.event_media)) // { // continue; // } // // if (eventi.media_type == "png" || eventi.media_type == "jpg" || eventi.media_type == "jpeg") // { // // listToDownload.Add(Constants.SERVICE_BASE_URL+eventi.event_media); // string fileName = System.IO.Path.GetFileName(eventi.event_media); // eventi.event_media = App.DownloadsPath + fileName; // } // else // { // eventi.event_media = Constants.SERVICE_BASE_URL + eventi.event_media ; // } // } // // if (listToDownload != null && listToDownload.Count > 0) { // IDownload downloader = DependencyService.Get<IDownload>(); // //progressBar.ShowProgressbar("loading details.."); // await downloader.DownloadFiles(listToDownload); // // } // // DetailsPageModel model = new DetailsPageModel(); // model.actionMediaArray = null; // model.eventMediaArray = eventDetails.event_media; // model.goal_media = null; // model.Media = null; // model.NoMedia = null; // model.pageTitleVal = "Event Details"; // model.titleVal = eventDetails.event_title; // model.description = eventDetails.event_details; // model.gemType = GemType.Event; // model.gemId = currentGemId; // progress.HideProgressbar(); // // await Navigation.PushAsync(new GemsDetailsPage(model)); // eventDetails = null; // } // } catch (Exception ) { // progress.HideProgressbar(); // Navigation.PopAsync(); // } // } // else // { // //-- call service for Action details // try { // // SelectedActionDetails actionDetails = await ServiceHelper.GetSelectedActionDetails(currentGemId); // // List<string> listToDownload = new List<string>(); // // foreach (var action in actionDetails.action_media) // { // if( string.IsNullOrEmpty(action.action_media)) // { // continue; // } // // if (action.media_type == "png" || action.media_type == "jpg" || action.media_type == "jpeg") // { // // listToDownload.Add(Constants.SERVICE_BASE_URL+action.action_media); // string fileName = System.IO.Path.GetFileName(action.action_media); // action.action_media = App.DownloadsPath + fileName; // } // else // { // action.action_media = Constants.SERVICE_BASE_URL + action.action_media; // } // } // // if (listToDownload != null && listToDownload.Count > 0) { // IDownload downloader = DependencyService.Get<IDownload>(); // //progressBar.ShowProgressbar("loading details.."); // await downloader.DownloadFiles(listToDownload); // //progressBar.HideProgressbar(); // } // // if (actionDetails != null) { // DetailsPageModel model = new DetailsPageModel(); // model.actionMediaArray = actionDetails.action_media; // model.eventMediaArray = null; // model.goal_media = null; // model.Media = null; // model.NoMedia = null; // model.pageTitleVal = "Action Details"; // model.titleVal = actionDetails.action_title; // model.description = actionDetails.action_details; // model.gemType = GemType.Action; // model.gemId = currentGemId; // // progress.HideProgressbar(); // await Navigation.PushAsync(new GemsDetailsPage(model)); // // // // // actionDetails = null; // } // } catch (Exception ) { // progress.HideProgressbar(); // Navigation.PopAsync(); // } // // #endregion } } } } catch (Exception ex) { var test = ex.Message; } }
protected virtual void NormalizeSelectorRoutes(string rootPath, string controllerName, ActionModel action, [CanBeNull] ConventionalControllerSetting configuration) { foreach (var selector in action.Selectors) { var httpMethod = selector.ActionConstraints .OfType <HttpMethodActionConstraint> () .FirstOrDefault() ? .HttpMethods? .FirstOrDefault(); if (httpMethod == null) { httpMethod = SelectHttpMethod(action, configuration); } if (selector.AttributeRouteModel == null) { selector.AttributeRouteModel = CreateRocketServiceAttributeRouteModel(rootPath, controllerName, action, httpMethod, configuration); } if (!selector.ActionConstraints.OfType <HttpMethodActionConstraint> ().Any()) { selector.ActionConstraints.Add(new HttpMethodActionConstraint(new [] { httpMethod })); } } }
public static async Task<bool> AddAction(ActionModel actionDetails) { if (!CrossConnectivity.Current.IsConnected) { return false; } try { string result = String.Empty; var client = new HttpClient(); client.Timeout = new TimeSpan(0, 15, 0); client.BaseAddress = new Uri(Constants.SERVICE_BASE_URL); client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "multipart/form-data"); var url = "api.php?action=actioninsert1"; MultipartFormDataContent content = new MultipartFormDataContent(); if (App.MediaArray != null && App.MediaArray.Count > 0) { for (int index = 0; index < App.MediaArray.Count; index++) { int imgIndex = index + 1; MediaItem media = App.MediaArray[index]; content.Add(new StringContent(media.MediaString, Encoding.UTF8), "action_media" + imgIndex.ToString()); content.Add(new StringContent(App.ExtentionArray[index], Encoding.UTF8), "file_type" + imgIndex.ToString()); if( media.MediaType != null && media.MediaType == Constants.MediaType.Video ) { content.Add(new StringContent(media.MediaThumbString, Encoding.UTF8), "video_thumb" + imgIndex.ToString()); } } content.Add(new StringContent(App.MediaArray.Count.ToString(), Encoding.UTF8), "media_count"); } if (App.ContactsArray != null && App.ContactsArray.Count > 0) { for (int index = 0; index < App.ContactsArray.Count; index++) { int contactsindex = index + 1; content.Add(new StringContent(App.ContactsArray[index], Encoding.UTF8), "contact_name" + contactsindex.ToString()); } content.Add(new StringContent(App.ContactsArray.Count.ToString(), Encoding.UTF8), "contact_count"); } if (!string.IsNullOrEmpty(actionDetails.start_date)) content.Add(new StringContent(actionDetails.start_date, Encoding.UTF8), "action_startdate"); if (!string.IsNullOrEmpty(actionDetails.end_date)) content.Add(new StringContent(actionDetails.end_date, Encoding.UTF8), "action_enddate"); if (!string.IsNullOrEmpty(actionDetails.start_time)) content.Add(new StringContent(actionDetails.start_time, Encoding.UTF8), "action_starttime"); if (!string.IsNullOrEmpty(actionDetails.end_time)) content.Add(new StringContent(actionDetails.end_time, Encoding.UTF8), "action_endtime"); if (!string.IsNullOrEmpty(actionDetails.location_latitude)) content.Add(new StringContent(actionDetails.location_latitude, Encoding.UTF8), "location_latitude"); if (!string.IsNullOrEmpty(actionDetails.location_longitude)) content.Add(new StringContent(actionDetails.location_longitude, Encoding.UTF8), "location_longitude"); if (!string.IsNullOrEmpty(actionDetails.location_address)) content.Add(new StringContent(actionDetails.location_address, Encoding.UTF8), "location_address"); if (!string.IsNullOrEmpty(actionDetails.action_repeat)) content.Add(new StringContent(actionDetails.action_repeat, Encoding.UTF8), "action_repeat"); if (!string.IsNullOrEmpty(actionDetails.action_alert)) content.Add(new StringContent(actionDetails.action_alert, Encoding.UTF8), "action_alert"); if (actionDetails.action_title != null && actionDetails.action_details != null && actionDetails.user_id != null) { content.Add(new StringContent(actionDetails.action_title, Encoding.UTF8), "action_title"); content.Add(new StringContent(actionDetails.action_details, Encoding.UTF8), "action_details"); content.Add(new StringContent(actionDetails.user_id, Encoding.UTF8), "user_id"); } if (!string.IsNullOrEmpty(actionDetails.action_id)) { content.Add(new StringContent(actionDetails.action_id, Encoding.UTF8), "goalaction_id"); } content.Add(new StringContent("1", Encoding.UTF8), "actionstatus_id");// to be confirmed - status id of new goal // for testing only // test content.Add(new StringContent("1", Encoding.UTF8), "category_id"); // category_id = 1 for testing only // test HttpResponseMessage response = await client.PostAsync(url, content); if (response != null && response.StatusCode == HttpStatusCode.OK) { var eventsJson = response.Content.ReadAsStringAsync().Result; var rootobject = JsonConvert.DeserializeObject<ResultJSon>(eventsJson); if (rootobject.code == "200") { client.Dispose(); App.ExtentionArray.Clear(); App.MediaArray.Clear(); return true; } } else { client.Dispose(); return false; } client.Dispose(); return false; } catch (Exception ex) { var test = ex.Message; return false; } }
protected virtual AttributeRouteModel CreateRocketServiceAttributeRouteModel(string rootPath, string controllerName, ActionModel action, string httpMethod, [CanBeNull] ConventionalControllerSetting configuration) { return(new AttributeRouteModel( new RouteAttribute( CalculateRouteTemplate(rootPath, controllerName, action, httpMethod, configuration) ) )); }
protected virtual string CalculateRouteTemplate(string rootPath, string controllerName, ActionModel action, string httpMethod, [CanBeNull] ConventionalControllerSetting configuration) { var controllerNameInUrl = NormalizeUrlControllerName(rootPath, controllerName, action, httpMethod, configuration); var url = $"api/{rootPath}/{controllerNameInUrl.ToCamelCase()}"; //Add {id} path if needed var idParameterModel = action.Parameters.FirstOrDefault(p => p.ParameterName == "id"); if (idParameterModel != null) { if (TypeHelper.IsPrimitiveExtended(idParameterModel.ParameterType, includeEnums: true)) { url += "/{id}"; } else { var properties = idParameterModel .ParameterType .GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (var property in properties) { url += "/{" + property.Name + "}"; } } } //Add action name if needed var actionNameInUrl = NormalizeUrlActionName(rootPath, controllerName, action, httpMethod, configuration); if (!actionNameInUrl.IsNullOrEmpty()) { url += $"/{actionNameInUrl.ToCamelCase()}"; //Add secondary Id var secondaryIds = action.Parameters.Where(p => p.ParameterName.EndsWith("Id", StringComparison.Ordinal)).ToList(); if (secondaryIds.Count == 1) { url += $"/{{{secondaryIds[0].ParameterName}}}"; } } return(url); }
private void ProcessAttributeModel(AttributeRouteModel attributeRouteModel, IEnumerable <string> prefixes, ODataControllerActionContext context, SelectorModel actionSelector, ActionModel actionModel, ControllerModel controllerModel, IDictionary <SelectorModel, IList <SelectorModel> > updatedSelectors) { if (attributeRouteModel == null) { // not an attribute routing, skip it. return; } string prefix = FindRelatedODataPrefix(attributeRouteModel.Template, prefixes, out string newRouteTemplate); if (prefix == null) { return; } IEdmModel model = context.Options.Models[prefix].Item1; IServiceProvider sp = context.Options.Models[prefix].Item2; SelectorModel newSelectorModel = CreateActionSelectorModel(prefix, model, sp, newRouteTemplate, actionSelector, attributeRouteModel.Template, actionModel.ActionName, controllerModel.ControllerName); if (newSelectorModel != null) { IList <SelectorModel> selectors; if (!updatedSelectors.TryGetValue(actionSelector, out selectors)) { selectors = new List <SelectorModel>(); updatedSelectors[actionSelector] = selectors; } selectors.Add(newSelectorModel); } }