コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        public static List <IDataItem> GetSearchConditionList(System.Web.Mvc.FormCollection formSearch, Dictionary <string, DataItem> dicSearchCondition)
        {
            if (formSearch == null || dicSearchCondition == null)
            {
                return(null);
            }

            List <IDataItem> listSearchCondition = new List <IDataItem>();

            foreach (string keyName in dicSearchCondition.Keys)
            {
                if (!formSearch[keyName].IsEmpty())
                {
                    /*
                     * 因为当用Html.CheckBoxFor在界面上呈现一个checkbox时,会自动生成一个同名的hidden控件,
                     * 这样,对选中的checkbox,form里传过来的值就是“true,false”;故对这样的情况,要特别如下处理一下
                     */
                    if (formSearch[keyName].Equals("true,false"))
                    {
                        dicSearchCondition[keyName].ItemData = true.ToString();
                    }
                    else
                    {
                        dicSearchCondition[keyName].ItemData = formSearch[keyName];
                    }
                    listSearchCondition.Add(dicSearchCondition[keyName]);
                }
            }
            return(listSearchCondition);
        }
コード例 #2
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            if (form["decision"] == "switch")
            {
                player.Team           = Team.Load(playerTask.data);
                player.MustReload     = true;
                player.GetTeam.score += 10;
                Notification n = Notification.CreateTeam("<b>" + player.Name + "</b> has switched teams and joined <b>" + player.GetTeam.name + "</b>.", player.GetTeam.id);
                player.ReadNotifications.Add(n.id);
                foreach (PlayerTask task in player.GetTasks)
                {
                    task.Delete();                                                          // delete all your waiting tasks
                }
                Notification.CreatePlayer("Welcome to <b>" + player.GetTeam.name + "</b>.", player.id);
            }
            else                 // stayed with current team
            {
                player.Rank += 8;
                Notification.CreatePlayer("<b>" + player.GetTeam.name + "</b> appreciates your continued and compulsory loyalty.", player.id);
            }

            player.Save();
        }
コード例 #3
0
        public HttpResponseMessage SaveTypes(HttpRequestMessage request, System.Web.Mvc.FormCollection form)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = request.CreateErrorResponse(HttpStatusCode.NotFound, "No items found");
                if (true)
                {
                    //activity log
                    _customerActivityService.InsertActivity("EditActivityLogTypes", _localizationService.GetResource("ActivityLog.EditActivityLogTypes"));

                    string formKey = "checkbox_activity_types";
                    var checkedActivityTypes = form[formKey] != null ? form[formKey].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt32(x)).ToList() : new List <int>();

                    var activityTypes = _customerActivityService.GetAllActivityTypes();
                    foreach (var activityType in activityTypes)
                    {
                        activityType.Enabled = checkedActivityTypes.Contains(activityType.Id);
                        _customerActivityService.UpdateActivityType(activityType);
                    }
                    _baseService.Commit();
                    var uri = Url.Link("ActivityListTypes", null);
                    response.Headers.Location = new Uri(uri);
                }
                return response;
            }));
        }
コード例 #4
0
        /// <summary>
        /// 将 System.Web.Mvc.FormCollection 集合 转换成 DataRow
        /// </summary>
        /// <param name="formCollection"></param>
        /// <param name="datarow"></param>
        public static void FormCollectionToDataRow(System.Web.Mvc.FormCollection formCollection, System.Data.DataRow datarow)
        {
            if (formCollection == null || datarow == null)
            {
                return;
            }

            foreach (string keyName in formCollection.AllKeys)
            {
                if (!datarow.Table.Columns.Contains(keyName))
                {
                    continue;
                }

                if (formCollection[keyName].IsEmpty())
                {
                    datarow[keyName] = DBNull.Value;
                }
                else
                {
                    /*
                     * 因为当用Html.CheckBoxFor在界面上呈现一个checkbox时,会自动生成一个同名的hidden控件,
                     * 这样,对选中的checkbox,form里传过来的值就是“true,false”;故对这样的情况,要特别如下处理一下
                     */
                    if (formCollection[keyName].Equals("true,false"))
                    {
                        datarow[keyName] = true;
                    }
                    else
                    {
                        datarow[keyName] = formCollection[keyName];
                    }
                }
            }
        }
コード例 #5
0
ファイル: EqmSv.cs プロジェクト: liyihan20/Ele_Sale
        public void SaveDeliveryBill(System.Web.Mvc.FormCollection fc, UserInfo user)
        {
            Sale_eqm_ch_bill bill = new Sale_eqm_ch_bill();

            SomeUtils.SetFieldValueToModel(fc, bill);
            List <Sale_eqm_ch_bill_detail> details = JsonConvert.DeserializeObject <List <Sale_eqm_ch_bill_detail> >(fc.Get("ch_bill_details"));

            bill.FUserName = user.realName;
            bill.FSaveDate = DateTime.Now;
            bill.Sale_eqm_ch_bill_detail.AddRange(details);

            if (string.IsNullOrEmpty(bill.FSysNo))
            {
                bill.FSysNo = GetNextSysNo();
            }
            else
            {
                var existedBill = db.Sale_eqm_ch_bill.Where(s => s.FSysNo == bill.FSysNo && (s.FDeleted == null || s.FDeleted == false)).FirstOrDefault();
                if (existedBill != null)
                {
                    existedBill.FDeleted = true;
                }
            }

            db.Sale_eqm_ch_bill.InsertOnSubmit(bill);
            db.SubmitChanges();
        }
コード例 #6
0
        public string GetReportData(string companyCode, string userName, System.Web.Mvc.FormCollection coll, string subDominName, out string error)
        {
            DALAPI      objdalAPI       = new DALAPI();
            CurrentInfo _objcurrentInfo = new CurrentInfo();
            Data        _objData        = new Data();
            int         apiID           = Convert.ToInt32(coll["APIId"]);
            string      serviceId       = coll["ServiceId"].ToString();
            //string ErrorMSG = string.Empty;
            string TransNumber     = Guid.NewGuid().ToString();
            string CurrentUserCode = _objcurrentInfo.GetUserCode();
            //string CurrentUserName = _objcurrentInfo.GetUserName();
            string        ConnectionString = _objData.GetConnectionString_Client();
            string        ExcelURL         = string.Empty;
            StringBuilder ParamDetails     = new StringBuilder();

            DataSet ds = GetAPIUIElements(apiID);

            object[] param = new object[ds.Tables[0].Rows.Count];
            int      i     = 0;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (dr["Show_In_UI"].ToString().ToUpper() == "N")
                {
                    param[i] = HttpContext.Current.Session[dr["Session_Key"].ToString()].ToString();
                }
                else
                {
                    if (dr["Type"].ToString() != "TEXT_CSV")
                    {
                        param[i] = coll[dr["InputParam"].ToString()].ToString();
                    }
                    else
                    {
                        // input string formate for TEXT_CSV aaa^bbb^ccc^bbbb^
                        string paramValue = coll[dr["InputParam"].ToString()].ToString();
                        paramValue = paramValue.Replace("^", "','");
                        paramValue = "'" + paramValue + "'";
                        param[i]   = paramValue;
                    }
                }
                ParamDetails.Append(dr["InputParam"].ToString() + ": " + param[i].ToString() + "<br />");
                i++;
            }

            //Log Bulk API SVC Log
            string hdLogId = Guid.NewGuid().ToString();
            string OutError;

            objdalAPI.BulkAPISvcLog(companyCode, userName, serviceId, hdLogId, apiID);
            HDCoreDataService.HDCoreDataServiceClient coreClt = new HDCoreDataService.HDCoreDataServiceClient();
            DataSet dsReport = new DataSet();

            dsReport = coreClt.ExecuteServiceDS("SWAAS", subDominName, apiID, "", "", 0, param, out OutError);

            // dsReport = coreClt.ExecuteServiceDS(out OutError,"SWAAS", subDominName, apiID, "", "", 0, param);
            error = "";
            return(bindReport(dsReport).ToString());
        }
コード例 #7
0
        public T LerFormulario(System.Web.Mvc.FormCollection form, T entity)
        {
            var s = entity;

            foreach (var p in s.GetType().GetProperties().Where(p => p.GetGetMethod().GetParameters().Count() == 0))
            {
                foreach (var key in form.Keys)
                {
                    try
                    {
                        if (p.Name == key.ToString())
                        {
                            if (p.Name == "ContratoNrcId")
                            {
                                p.SetValue(s, Convert.ToInt32(form[key.ToString()]));
                            }
                            if (p.Name == "TipoClienteFaturamentoId")
                            {
                                p.SetValue(s, Convert.ToInt32(form[key.ToString()]));
                            }
                            if (p.Name == "ContratoId")
                            {
                                p.SetValue(s, Convert.ToInt32(form[key.ToString()]));
                            }

                            if (p.PropertyType.Name == "Int32")
                            {
                                p.SetValue(s, Convert.ToInt32(form[key.ToString()]));
                            }
                            if (p.PropertyType.Name == "String")
                            {
                                p.SetValue(s, form[key.ToString()]);
                            }
                            if (p.PropertyType.Name == "DateTime")
                            {
                                p.SetValue(s, Convert.ToDateTime(form[key.ToString()]));
                            }
                            if (p.PropertyType.Name == "Bool")
                            {
                                p.SetValue(s, Convert.ToBoolean(form[key.ToString()]));
                            }
                            if (p.PropertyType.Name == "Decimal")
                            {
                                p.SetValue(s, Convert.ToDecimal(form[key.ToString()]));
                            }
                            if (p.PropertyType.Name == "Double")
                            {
                                p.SetValue(s, Convert.ToDouble(form[key.ToString()]));
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }

            return(s);
        }
コード例 #8
0
ファイル: CHSv.cs プロジェクト: liyihan20/Ele_Sale
        public override string SaveBill(System.Web.Mvc.FormCollection fc, UserInfo user)
        {
            bill = new ChBill();
            SomeUtils.SetFieldValueToModel(fc, bill);
            List <ChBillDetail> details = JsonConvert.DeserializeObject <List <ChBillDetail> >(fc.Get("ch_bill_details"));

            bill.ChBillDetail.AddRange(details);

            try {
                //保存送货地址信息
                var dInfos = new OtherSv().GetDeliveryInfo(bill.customer_no)
                             .Where(d => d.deliveryUnit == bill.delivery_unit && d.attn == bill.delivery_attn &&
                                    d.addr == bill.delivery_addr && d.phone == bill.delivery_phone).Count();
                if (dInfos == 0)
                {
                    var info = new CustomerDeliveryInfo()
                    {
                        customer_name   = bill.customer_name,
                        customer_number = bill.customer_no,
                        delivery_unit   = bill.delivery_unit,
                        addr            = bill.delivery_addr,
                        attn            = bill.delivery_attn,
                        phone           = bill.delivery_phone,
                        op_date         = DateTime.Now,
                        op_name         = user.realName
                    };
                    db.CustomerDeliveryInfo.InsertOnSubmit(info);
                }

                var existsed = db.ChBill.Where(c => c.sys_no == bill.sys_no).ToList();
                if (existsed.Count() > 0)
                {
                    //备份旧单
                    BackupData bd = new BackupData();
                    bd.sys_no         = bill.sys_no;
                    bd.op_date        = DateTime.Now;
                    bd.user_id        = user.userId;
                    bd.main_data      = SomeUtils.ModelToString <ChBill>(existsed.First());
                    bd.secondary_data = SomeUtils.ModelsToString <ChBillDetail>(existsed.First().ChBillDetail.ToList());
                    db.BackupData.InsertOnSubmit(bd);

                    //删掉旧单
                    db.ChBillDetail.DeleteAllOnSubmit(existsed.First().ChBillDetail);
                    db.ChBill.DeleteAllOnSubmit(existsed);
                }
                bill.bill_date = DateTime.Now;
                bill.user_id   = user.userId;

                db.ChBill.InsertOnSubmit(bill);
                db.ChBillDetail.InsertAllOnSubmit(bill.ChBillDetail);
                db.SubmitChanges();
            }
            catch (Exception ex) {
                return(ex.Message);
            }

            return("");
        }
コード例 #9
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            // data submitted; log it and continue to wait
            if (form["data"] != null)
            {
                playerTask.data = playerTask.data.Split(',')[0] + "," + form["data"];
                playerTask.Save();
                return;
            }

            // all submissions have been made
            string status = GetStatus(playerTask);

            if (status == "")
            {
                return;
            }

            // personal bonus for getting it right
            if (Convert.ToInt32(playerTask.data.Split(',')[1]) == GetProduct())
            {
                player.Rank += 10;
            }
            else
            {
                player.Rank -= 10;
                Notification.CreatePlayer(string.Join(" x ", GetSummitTasks().Select(o => o.data.Split(',')[0])) + " = " + GetProduct() + ". Duh.", player.id);
            }
            player.Save();

            if (IsPrimary(playerTask))
            {
                if (status == "True")
                {
                    foreach (var pt in GetSummitTasks())
                    {
                        pt.GetPlayer.GetTeam.score += 15;
                        pt.GetPlayer.GetTeam.Save();
                    }
                    Newsfeed.Create("The Earth Plutocratic Congress Interagency Technology Summit is once again an overwhelming success.", Newsfeed.Context.success);
                }
                else
                {
                    foreach (var pt in GetSummitTasks())
                    {
                        pt.GetPlayer.GetTeam.score -= 8;
                        pt.GetPlayer.GetTeam.Save();
                    }

                    Newsfeed.Create("Tragedy at the Earth Plutocratic Congress Interagency Technology Summit caused by a simple mathematical error.", Newsfeed.Context.warning);
                }
            }

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
コード例 #10
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            player.AddItem(playerTask.data);
        }
コード例 #11
0
        public decimal GetWeighingCount(System.Web.Mvc.FormCollection collection, Questionnaire questionnaire)
        {
            decimal sum = 0;

            foreach (Category cat in questionnaire.Categories)
            {
                sum += decimal.Parse(collection["weighing." + cat.Id]);
            }
            return(sum);
        }
コード例 #12
0
        public bool IsWeighingNull(System.Web.Mvc.FormCollection collection, Questionnaire questionnaire)
        {
            bool validate = true;

            foreach (Category cat in questionnaire.Categories)
            {
                validate = validate && (collection["weighing." + cat.Id] != "");
            }
            return(!validate);
        }
コード例 #13
0
        public static string ToJSON(this System.Web.Mvc.FormCollection collection)
        {
            var list = new Dictionary <string, string>();

            foreach (string key in collection.Keys)
            {
                list.Add(key, collection[key]);
            }
            return(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(list));
        }
コード例 #14
0
        public int PlaceOrder()
        {
            System.Web.Mvc.FormCollection collection = new System.Web.Mvc.FormCollection();
            Task <string> content = this.Request.Content.ReadAsStringAsync();
            int           body    = JsonConvert.DeserializeObject <int>(content.Result);

            collection.Add(FormDataKeys.DeliveryAddress.ToString(), body.ToString());
            CreateOrderResponse createOrderResponse = this.checkoutController.CreateOrderResponse(collection);

            return(createOrderResponse.Order.Id);
        }
コード例 #15
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            player.idle       = false;
            player.IdleUpdate = null;
            player.Save();

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
コード例 #16
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            if (form["data"] == playerTask.data.Substring(0, 4))
            {
                Player player = Player.Load(playerTask.playerId);
                player.Rank += 13;
                player.Save();
            }
        }
コード例 #17
0
        internal void CreateEmptyWord(System.Web.Mvc.FormCollection collection)
        {
            LogHelper.Log("INside CreateEmptyWord");
            ListItem NewEmptyWord = ctx.Web.Lists.GetByTitle(Constants.EmptyWordsList).AddItem(
                new ListItemCreationInformation());

            NewEmptyWord[Constants.TitleField] = collection["word"];
            NewEmptyWord[Constants.LangField]  = collection["lang"];
            NewEmptyWord.Update();
            ctx.ExecuteQuery();
            LogHelper.Log("INside CreateEmptyWord after ExecuteQuery");
        }
コード例 #18
0
        public override string SaveBill(System.Web.Mvc.FormCollection fc, UserInfo user)
        {
            bill = new Sale_eo_bill();
            SomeUtils.SetFieldValueToModel(fc, bill);
            bill.Sale_eo_bill_detail.AddRange(JsonConvert.DeserializeObject <List <Sale_eo_bill_detail> >(fc.Get("details")));

            if (string.IsNullOrEmpty(bill.clerk_no))
            {
                return("营业员请输入厂牌或姓名然后按回车键搜索后,在列表中选择");
            }

            try {
                var existedBill = db.Sale_eo_bill.Where(s => s.sys_no == bill.sys_no).FirstOrDefault();
                if (existedBill != null)
                {
                    bill.applier_id   = existedBill.applier_id;
                    bill.applier_name = existedBill.applier_name;
                    bill.apply_time   = existedBill.apply_time;

                    //备份
                    JsonSerializerSettings js = new JsonSerializerSettings()
                    {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    };
                    BackupData bd = new BackupData();
                    bd.op_date        = DateTime.Now;
                    bd.sys_no         = existedBill.sys_no;
                    bd.user_id        = user.userId;
                    bd.main_data      = JsonConvert.SerializeObject(existedBill, js);
                    bd.secondary_data = JsonConvert.SerializeObject(existedBill.Sale_eo_bill_detail, js);
                    db.BackupData.InsertOnSubmit(bd);

                    //删除
                    db.Sale_eo_bill_detail.DeleteAllOnSubmit(existedBill.Sale_eo_bill_detail);
                    db.Sale_eo_bill.DeleteOnSubmit(existedBill);
                }
                else
                {
                    bill.applier_id   = user.userId;
                    bill.applier_name = user.realName;
                    bill.apply_time   = DateTime.Now;
                }

                db.Sale_eo_bill.InsertOnSubmit(bill);
                db.Sale_eo_bill_detail.InsertAllOnSubmit(bill.Sale_eo_bill_detail);
                db.SubmitChanges();
            }
            catch (Exception ex) {
                return(ex.Message);
            }
            return("");
        }
コード例 #19
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player         = Player.Load(playerTask.playerId);
            int    opponentTaskId = Convert.ToInt32(playerTask.data.Split(',')[0]);

            // player has made their choice
            if (form["choice"] != null)
            {
                playerTask.data = opponentTaskId + "," + form["choice"];
                playerTask.Save();
                return;
            }

            // both players have made their choices
            PlayerTask opponentTask = PlayerTask.Load(opponentTaskId);

            string myChoice       = playerTask.data.Split(',')[1];
            string opponentChoice = opponentTask.data.Split(',')[1];

            if (myChoice == "coop" && opponentChoice == "coop")
            {
                Notification.CreatePlayer("Both you and <b>" + opponentTask.GetPlayer.Name + "</b> cooperated with one another and have received your just rewards.", player.id);
                player.Rank += 12;
                player.Save();

                player.GetTeam.score += 13;
                player.GetTeam.Save();

                player.GiveRandomItem(Math.Min(player.AvailableItemSlots, 2));
            }
            else if (myChoice == "betray" && opponentChoice == "coop")
            {
                Notification.CreatePlayer("You betrayed <b>" + opponentTask.GetPlayer.Name + "</b> while they tried to cooperate with you.", player.id);
                player.GiveRandomItem(Math.Min(player.AvailableItemSlots, 1));
            }
            else if (myChoice == "coop" && opponentChoice == "betray")
            {
                Notification.CreatePlayer("You were betrayed by <b>" + opponentTask.GetPlayer.Name + "</b>.", player.id);
                player.Rank -= 10;
                player.Save();
            }
            else                 // betray/betray
            {
                Notification.CreatePlayer("You both betrayed one another.", player.id);
                player.Rank += 10;
                player.Save();
            }

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
コード例 #20
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            // player has started their device
            if (form["start"] != null)
            {
                playerTask.data = form["start"] + "," + DateTime.Now.Ticks;
                playerTask.Save();
                return;
            }

            // timing failed!
            if (GetStatus(playerTask).StartsWith("Fail"))
            {
                // only do these things once
                if (IsPrimaryTask(playerTask))
                {
                    Notification.CreateTeam("An explosion rocks the primary laboratory! Your team's lead researchers have failed to properly assembly the final construction. Minor damage results.", player.teamId);
                    player.GetTeam.score -= 20;                     // drop a tech level, but the items are not destroyed
                    player.GetTeam.Save();
                }

                playerTask.State = Task.TaskState.Completed;
                playerTask.Save();
                return;
            }

            // success
            if (GetStatus(playerTask).StartsWith("Done"))
            {
                // only do these things once
                if (IsPrimaryTask(playerTask))
                {
                    Notification.CreateTeam("A stillness descends over the primary laboratory. Your team's lead researchers have assembled the final form of the strange alien technology and made it available to all agents.", player.teamId);
                    // delete everyone's items and give them all the final form
                    foreach (Player p in player.GetTeam.GetPlayers)
                    {
                        foreach (PlayerItem item in p.GetItems)
                        {
                            item.Delete();
                        }
                        p.AddItem("timemachine");
                    }
                }

                playerTask.State = Task.TaskState.Completed;
                playerTask.Save();
                return;
            }
        }
コード例 #21
0
        internal static JObject GetCarrierRates(System.Web.Mvc.FormCollection form)
        {
            List <CarrierRateVm> carrRateList = CarrierRateHelper.GetCarrierRatesInquiry(form);

            JTokenWriter pJTokenWriter = new JTokenWriter();
            JObject      ordersJson    = new JObject();

            pJTokenWriter.WriteStartObject();
            pJTokenWriter.WritePropertyName("data");
            pJTokenWriter.WriteStartArray();

            foreach (var item in carrRateList)
            {
                pJTokenWriter.WriteStartObject();

                pJTokenWriter.WritePropertyName("CarrierRateId");
                pJTokenWriter.WriteValue(item.CarrierRateId);

                pJTokenWriter.WritePropertyName("CarrierName");
                pJTokenWriter.WriteValue(item.CarrierName);

                pJTokenWriter.WritePropertyName("ContainerTypeName");
                pJTokenWriter.WriteValue(item.ContainerTypeName);

                pJTokenWriter.WritePropertyName("FromPort");
                pJTokenWriter.WriteValue(item.FromCountryName + " / " + item.FromPortName);

                pJTokenWriter.WritePropertyName("ToPort");
                pJTokenWriter.WriteValue(item.ToCountryName + " / " + item.ToPortName);

                pJTokenWriter.WritePropertyName("FreightCost");
                pJTokenWriter.WriteValue(item.FreightCostAmount + "  " + item.FreighCurrencySign);

                pJTokenWriter.WritePropertyName("ThcCost");
                pJTokenWriter.WriteValue(item.ThcCostAmount + "  " + item.ThcCurrencySign);

                pJTokenWriter.WritePropertyName("ValidToDate");
                pJTokenWriter.WriteValue(item.ValidToDate == null ? "" : item.ValidToDate.Value.ToString("dd/MM/yyyy"));

                pJTokenWriter.WritePropertyName("CarrierId");
                pJTokenWriter.WriteValue(item.CarrierId);

                pJTokenWriter.WriteEndObject();
            }

            pJTokenWriter.WriteEndArray();
            pJTokenWriter.WriteEndObject();
            ordersJson = (JObject)pJTokenWriter.Token;
            return(ordersJson);
        }
コード例 #22
0
        public HttpResponseMessage PermissionsSave(HttpRequestMessage request, System.Web.Mvc.FormCollection form)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = request.CreateErrorResponse(HttpStatusCode.NotFound, "No items found");
                if (true)
                {
                    var permissionRecords = _permissionService.GetAllPermissionRecords();
                    var customerRoles = _customerService.GetAllCustomerRoles(true);


                    foreach (var cr in customerRoles)
                    {
                        string formKey = "allow_" + cr.Id;
                        var permissionRecordSystemNamesToRestrict = form[formKey] != null ? form[formKey].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() : new List <string>();

                        foreach (var pr in permissionRecords)
                        {
                            bool allow = permissionRecordSystemNamesToRestrict.Contains(pr.SystemName);
                            if (allow)
                            {
                                if (pr.CustomerRoles.FirstOrDefault(x => x.Id == cr.Id) == null)
                                {
                                    pr.CustomerRoles.Add(cr);
                                    _permissionService.UpdatePermissionRecord(pr);
                                }
                            }
                            else
                            {
                                if (pr.CustomerRoles.FirstOrDefault(x => x.Id == cr.Id) != null)
                                {
                                    pr.CustomerRoles.Remove(cr);
                                    _permissionService.UpdatePermissionRecord(pr);
                                }
                            }
                        }
                    }

                    //SuccessNotification(_localizationService.GetResource("Admin.Configuration.ACL.Updated"));
                    Url.Route("Permissions", null);
                    string uri = Url.Link("Permissions", null);
                    response.Headers.Location = new Uri(uri);
                }
                else
                {
                    return AccessDeniedView(request);
                }
                return response;
            }));
        }
コード例 #23
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            if (form["data"] != playerTask.data.Split(',')[1])
            {
                return;
            }

            Player player = Player.Load(playerTask.playerId);

            player.Rank += 12;
            player.Save();

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
コード例 #24
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            PlayerItem acquiredItem = PlayerItem.Load(form["data"]);

            acquiredItem.Delete();
            player.AddItem(acquiredItem.itemId);

            player.Rank += 9;
            player.Save();
        }
コード例 #25
0
ファイル: MyUtils.cs プロジェクト: liyihan20/VendorNew
 /// <summary>
 /// 使用反射将表单的值设置到数据库对象中,根据字段名
 /// </summary>
 /// <param name="col">表单</param>
 /// <param name="obj">数据库对象</param>
 public static void SetFieldValueToModel(System.Web.Mvc.FormCollection col, object obj)
 {
     foreach (var p in obj.GetType().GetProperties())
     {
         string val   = col.Get(p.Name);         //字段值
         string pType = p.PropertyType.FullName; //数据类型
         if (string.IsNullOrEmpty(val) || val.Equals("null"))
         {
             continue;
         }
         if (pType.Contains("DateTime"))
         {
             DateTime dt;
             if (DateTime.TryParse(val, out dt))
             {
                 p.SetValue(obj, dt, null);
             }
         }
         else if (pType.Contains("Int32"))
         {
             int i;
             if (int.TryParse(val, out i))
             {
                 p.SetValue(obj, i, null);
             }
         }
         else if (pType.Contains("Decimal"))
         {
             decimal dm;
             if (decimal.TryParse(val, out dm))
             {
                 p.SetValue(obj, dm, null);
             }
         }
         else if (pType.Contains("String"))
         {
             p.SetValue(obj, val.Trim(), null);
         }
         else if (pType.Contains("Bool"))
         {
             bool bl;
             if (bool.TryParse(val, out bl))
             {
                 p.SetValue(obj, bl, null);
             }
         }
     }
 }
コード例 #26
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            if (form["itemId"] != null)
            {
                Item item = player.GetTeam.WarehouseRetrieveItem(form["itemId"]);
                player.AddItem(item.id);

                player.Rank += 9;
                player.Save();
            }

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
コード例 #27
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            player.Rank += 12;
            player.Save();

            player.GetTeam.score += 9;
            player.GetTeam.Save();

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            player.RemoveItem("egg");
            player.AddItem("albumen");
        }
コード例 #28
0
        //Inquiry
        public static List <CarrierRateVm> GetCarrierRatesInquiry(System.Web.Mvc.FormCollection form)
        {
            EasyFreightEntities db = new EasyFreightEntities();

            List <CarrierRateVm> carrRateVmList = GetCarrierRatesList(true);

            if (form == null || form.AllKeys.Count() == 0)
            {
                return(carrRateVmList);
            }

            if (!string.IsNullOrEmpty(form["CarrierId"]))
            {
                int carrId = int.Parse(form["CarrierId"]);
                carrRateVmList = carrRateVmList.Where(x => x.CarrierId == carrId).ToList();
            }
            if (!string.IsNullOrEmpty(form["ContainerTypeId"]))
            {
                int contId = int.Parse(form["ContainerTypeId"]);
                carrRateVmList = carrRateVmList.Where(x => x.ContainerTypeId == contId).ToList();
            }
            if (!string.IsNullOrEmpty(form["FromPortId"]))
            {
                int fromPortId = int.Parse(form["FromPortId"]);
                carrRateVmList = carrRateVmList.Where(x => x.FromPortId == fromPortId).ToList();
            }

            if (!string.IsNullOrEmpty(form["ToPortId"]))
            {
                int toPortId = int.Parse(form["ToPortId"]);
                carrRateVmList = carrRateVmList.Where(x => x.ToPortId == toPortId).ToList();
            }

            if (!string.IsNullOrEmpty(form["FromDate"]))
            {
                DateTime validDate = DateTime.Parse(form["FromDate"]);
                carrRateVmList = carrRateVmList.Where(x => x.ValidToDate >= validDate).ToList();
            }

            if (!string.IsNullOrEmpty(form["ToDate"]))
            {
                DateTime validDate = DateTime.Parse(form["ToDate"]);
                carrRateVmList = carrRateVmList.Where(x => x.ValidToDate <= validDate).ToList();
            }

            return(carrRateVmList);
        }
コード例 #29
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            player.Rank += 9;
            player.Save();

            player.GetTeam.score += 5;
            player.GetTeam.Save();

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            Item startItem = player.GiveRandomItem(1).GetItem;

            Notification.CreatePlayer("Welcome to the <b>" + player.GetTeam.name + "</b> team, agent <b>" + player.Name + "</b>. We've given you this <b>" + startItem.name + "</b> to help get you started.", player.id);
        }
コード例 #30
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            player.Rank += 12;
            player.Save();

            Player targetPlayer = Player.Load(new Guid(playerTask.data));
            Item   item         = Item.Load(form["itemId"]);

            targetPlayer.AddItem(item.id);
            targetPlayer.Rank += 10;
            targetPlayer.Save();

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }