public void Remove()
    {
      JObject o = new JObject();
      o.Add("PropertyNameValue", new JValue(1));
      Assert.AreEqual(1, o.Children().Count());

      Assert.AreEqual(false, o.Remove("sdf"));
      Assert.AreEqual(false, o.Remove(null));
      Assert.AreEqual(true, o.Remove("PropertyNameValue"));

      Assert.AreEqual(0, o.Children().Count());
    }
 private static void TestObject(JObject expected, JsonReader reader, string path)
 {
     reader.MoveToContent();
     Assert.AreEqual(reader.Token, JsonToken.Object);
     
     while (reader.ReadToken() != JsonToken.EndObject)
     {
         Assert.AreEqual(JsonToken.Member, reader.Token);
         
         string name = reader.Text;
         object value = expected[name];
         expected.Remove(name);
         TestValue(value, reader, path + "/" + name);
     }
     
     Assert.AreEqual(0, expected.Count);
 }
        public void IListRemoveAt()
        {
            JProperty p1 = new JProperty("Test1", 1);
            JProperty p2 = new JProperty("Test2", "Two");
            IList l = new JObject(p1, p2);

            // won't do anything
            l.RemoveAt(0);

            l.Remove(p1);
            Assert.Equal(1, l.Count);

            l.Remove(p2);
            Assert.Equal(0, l.Count);
        }
        public void IListRemove()
        {
            JProperty p1 = new JProperty("Test1", 1);
            JProperty p2 = new JProperty("Test2", "Two");
            IList l = new JObject(p1, p2);

            JProperty p3 = new JProperty("Test3", "III");

            // won't do anything
            l.Remove(p3);
            Assert.Equal(2, l.Count);

            l.Remove(p1);
            Assert.Equal(1, l.Count);
            Assert.False(l.Contains(p1));
            Assert.True(l.Contains(p2));

            l.Remove(p2);
            Assert.Equal(0, l.Count);
            Assert.False(l.Contains(p2));
            Assert.Equal(null, p2.Parent);
        }
        public void EmptyObjectDeepEquals()
        {
            Assert.True(JToken.DeepEquals(new JObject(), new JObject()));

            JObject a = new JObject();
            JObject b = new JObject();

            b.Add("hi", "bye");
            b.Remove("hi");

            Assert.True(JToken.DeepEquals(a, b));
            Assert.True(JToken.DeepEquals(b, a));
        }
    public void GenericListJTokenRemoveAt()
    {
      JProperty p1 = new JProperty("Test1", 1);
      JProperty p2 = new JProperty("Test2", "Two");
      IList<JToken> l = new JObject(p1, p2);

      // won't do anything
      l.RemoveAt(0);

      l.Remove(p1);
      Assert.AreEqual(1, l.Count);

      l.Remove(p2);
      Assert.AreEqual(0, l.Count);
    }
        public static object[] MapArguments(IRpcMethodDescriptor method, object argsObject)
        {
            object[] args;
            IDictionary argsMap = argsObject as IDictionary;

            if (argsMap != null)
            {
                JObject namedArgs = new JObject(argsMap);
                
                IRpcParameterDescriptor[] parameters = method.GetParameters();
                args = new object[parameters.Length];

                for (int i = 0; i < parameters.Length; i++)
                {
                    args[i] = namedArgs[parameters[i].Name];
                    namedArgs.Remove(parameters[i].Name);
                }

                foreach (DictionaryEntry entry in namedArgs)
                {
                    if (entry.Key == null)
                        continue;

                    string key = entry.Key.ToString();
                    
                    char ch1;
                    char ch2;

                    if (key.Length == 2)
                    {
                        ch1 = key[0];
                        ch2 = key[1];
                    }
                    else if (key.Length == 1)
                    {
                        ch1 = '0';
                        ch2 = key[0];
                    }
                    else
                    {
                        continue;
                    }

                    if (ch1 >= '0' && ch1 < '9' &&
                        ch2 >= '0' && ch2 < '9')
                    {
                        int index = int.Parse(key, NumberStyles.Number, CultureInfo.InvariantCulture);
                        
                        if (index < parameters.Length)
                            args[index] = entry.Value;
                    }
                }

                return args;
            }
            else
            {
                args = CollectionHelper.ToArray((ICollection) argsObject);
            }

            return JsonRpcServices.TransposeVariableArguments(method, args);
        }
    public void GenericListJTokenRemove()
    {
      JProperty p1 = new JProperty("Test1", 1);
      JProperty p2 = new JProperty("Test2", "Two");
      IList<JToken> l = new JObject(p1, p2);

      JProperty p3 = new JProperty("Test3", "III");

      // won't do anything
      Assert.IsFalse(l.Remove(p3));
      Assert.AreEqual(2, l.Count);

      Assert.IsTrue(l.Remove(p1));
      Assert.AreEqual(1, l.Count);
      Assert.IsFalse(l.Contains(p1));
      Assert.IsTrue(l.Contains(p2));

      Assert.IsTrue(l.Remove(p2));
      Assert.AreEqual(0, l.Count);
      Assert.IsFalse(l.Contains(p2));
      Assert.AreEqual(null, p2.Parent);
    }
Example #9
0
        public void fromJSON(string json)
        {
            JObject jWeaponMode = JObject.Parse(json);

            if (jWeaponMode["Id"] != null)
            {
                this.Id = (string)jWeaponMode["Id"];
            }
            if (jWeaponMode["UIName"] != null)
            {
                this.UIName = (string)jWeaponMode["UIName"];
            }
            if (jWeaponMode["AccuracyModifier"] != null)
            {
                this.AccuracyModifier = (float)jWeaponMode["AccuracyModifier"];
            }
            if (jWeaponMode["DamagePerShot"] != null)
            {
                this.DamagePerShot = (float)jWeaponMode["DamagePerShot"];
            }
            if (jWeaponMode["HeatDamagePerShot"] != null)
            {
                this.HeatDamagePerShot = (float)jWeaponMode["HeatDamagePerShot"];
            }
            if (jWeaponMode["HeatGenerated"] != null)
            {
                this.HeatGenerated = (int)jWeaponMode["HeatGenerated"];
            }
            if (jWeaponMode["ProjectilesPerShot"] != null)
            {
                this.ProjectilesPerShot = (int)jWeaponMode["ProjectilesPerShot"];
            }
            if (jWeaponMode["ShotsWhenFired"] != null)
            {
                this.ShotsWhenFired = (int)jWeaponMode["ShotsWhenFired"];
            }
            if (jWeaponMode["CriticalChanceMultiplier"] != null)
            {
                this.CriticalChanceMultiplier = (float)jWeaponMode["CriticalChanceMultiplier"];
            }
            if (jWeaponMode["AIBattleValue"] != null)
            {
                this.AIBattleValue = (int)jWeaponMode["AIBattleValue"];
            }
            if (jWeaponMode["MinRange"] != null)
            {
                this.MinRange = (float)jWeaponMode["MinRange"];
            }
            if (jWeaponMode["MaxRange"] != null)
            {
                this.MaxRange = (float)jWeaponMode["MaxRange"];
            }
            if (jWeaponMode["ShortRange"] != null)
            {
                this.ShortRange = (float)jWeaponMode["ShortRange"];
            }
            if (jWeaponMode["ForbiddenRange"] != null)
            {
                this.ForbiddenRange = (float)jWeaponMode["ForbiddenRange"];
            }
            if (jWeaponMode["MediumRange"] != null)
            {
                this.MediumRange = (float)jWeaponMode["MediumRange"];
            }
            if (jWeaponMode["LongRange"] != null)
            {
                this.LongRange = (float)jWeaponMode["LongRange"];
            }
            if (jWeaponMode["RefireModifier"] != null)
            {
                this.RefireModifier = (int)jWeaponMode["RefireModifier"];
            }
            if (jWeaponMode["isBaseMode"] != null)
            {
                this.isBaseMode = (bool)jWeaponMode["isBaseMode"];
            }
            if (jWeaponMode["Instability"] != null)
            {
                this.Instability = (float)jWeaponMode["Instability"];
            }
            if (jWeaponMode["AttackRecoil"] != null)
            {
                this.AttackRecoil = (int)jWeaponMode["AttackRecoil"];
            }
            if (jWeaponMode["WeaponEffectID"] != null)
            {
                this.WeaponEffectID = (string)jWeaponMode["WeaponEffectID"];
            }
            if (jWeaponMode["EvasivePipsIgnored"] != null)
            {
                this.EvasivePipsIgnored = (float)jWeaponMode["EvasivePipsIgnored"];
            }
            if (jWeaponMode["IndirectFireCapable"] != null)
            {
                this.IndirectFireCapable = ((bool)jWeaponMode["IndirectFireCapable"] == true) ? TripleBoolean.True : TripleBoolean.False;
            }
            if (jWeaponMode["DirectFireModifier"] != null)
            {
                this.DirectFireModifier = (float)jWeaponMode["DirectFireModifier"];
            }
            if (jWeaponMode["DistantVariance"] != null)
            {
                this.DistantVariance = (float)jWeaponMode["DistantVariance"];
            }
            if (jWeaponMode["DamageMultiplier"] != null)
            {
                this.DamageMultiplier = (float)jWeaponMode["DamageMultiplier"];
            }
            if (jWeaponMode["DistantVarianceReversed"] != null)
            {
                this.DistantVarianceReversed = ((bool)jWeaponMode["DistantVarianceReversed"] == true) ? TripleBoolean.True : TripleBoolean.False;
            }
            if (jWeaponMode["DamageVariance"] != null)
            {
                this.DamageVariance = (float)jWeaponMode["DamageVariance"];
            }
            if (jWeaponMode["FlatJammingChance"] != null)
            {
                this.FlatJammingChance = (float)jWeaponMode["FlatJammingChance"];
            }
            if (jWeaponMode["GunneryJammingBase"] != null)
            {
                this.GunneryJammingBase = (float)jWeaponMode["GunneryJammingBase"];
            }
            if (jWeaponMode["GunneryJammingMult"] != null)
            {
                this.GunneryJammingMult = (float)jWeaponMode["GunneryJammingMult"];
            }
            if (jWeaponMode["AIHitChanceCap"] != null)
            {
                this.AIHitChanceCap = (float)jWeaponMode["AIHitChanceCap"];
            }
            if (jWeaponMode["Cooldown"] != null)
            {
                this.Cooldown = (int)jWeaponMode["Cooldown"];
            }
            if (jWeaponMode["AmmoCategory"] != null)
            {
                this.AmmoCategory = CustomAmmoCategories.find((string)jWeaponMode["AmmoCategory"]);
            }
            if (jWeaponMode["DamageOnJamming"] != null)
            {
                this.DamageOnJamming = ((bool)jWeaponMode["DamageOnJamming"] == true) ? TripleBoolean.True : TripleBoolean.False;
            }
            if (jWeaponMode["AOECapable"] != null)
            {
                this.AOECapable = ((bool)jWeaponMode["AOECapable"] == true) ? TripleBoolean.True : TripleBoolean.False;;
            }
            if (jWeaponMode["AlwaysIndirectVisuals"] != null)
            {
                this.AlwaysIndirectVisuals = ((bool)jWeaponMode["AlwaysIndirectVisuals"] == true) ? TripleBoolean.True : TripleBoolean.False;
            }
            if (jWeaponMode["HitGenerator"] != null)
            {
                try {
                    this.HitGenerator = (HitGeneratorType)Enum.Parse(typeof(HitGeneratorType), (string)jWeaponMode["HitGenerator"], true);
                } catch (Exception e) {
                    this.HitGenerator = HitGeneratorType.NotSet;
                }
                jWeaponMode.Remove("HitGenerator");
            }
            if (jWeaponMode["statusEffects"] != null)
            {
                if (jWeaponMode["statusEffects"].Type == JTokenType.Array)
                {
                    this.statusEffects.Clear();
                    JToken statusEffects = jWeaponMode["statusEffects"];
                    foreach (JObject statusEffect in statusEffects)
                    {
                        EffectData effect = new EffectData();
                        JSONSerializationUtility.FromJSON <EffectData>(effect, statusEffect.ToString());
                        this.statusEffects.Add(effect);
                    }
                }
            }
        }
        /// <summary>
        /// Converts a type to a JSON schema in OpenAPI format.
        /// </summary>
        /// <param name="type">The type to be converted.</param>
        /// <returns>The type as JSON schema in OpenAPI format.</returns>
        public static JObject GetJsonSchemaOfType(Type type)
        {
            new PrimitiveTypeMapper(typeof(bool), (s) =>
            {
                s.Type = JsonObjectType.String;
            });

            JsonSchemaGeneratorSettings settings = new JsonSchemaGeneratorSettings
            {
                DefaultReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull,
                SchemaType  = SchemaType.Swagger2,
                TypeMappers =
                {
                    new PrimitiveTypeMapper(typeof(char), (s) =>
                    {
                        s.Type = JsonObjectType.String;
                    }),
                    new PrimitiveTypeMapper(typeof(byte), (s) =>
                    {
                        s.Type    = JsonObjectType.Integer;
                        s.Format  = JsonFormatStrings.Integer;
                        s.Minimum = byte.MinValue;
                        s.Maximum = byte.MaxValue;
                    }),
                    new PrimitiveTypeMapper(typeof(sbyte), (s) =>
                    {
                        s.Type    = JsonObjectType.Integer;
                        s.Format  = JsonFormatStrings.Integer;
                        s.Minimum = sbyte.MinValue;
                        s.Maximum = sbyte.MaxValue;
                    }),
                    new PrimitiveTypeMapper(typeof(short), (s) =>
                    {
                        s.Type    = JsonObjectType.Integer;
                        s.Format  = JsonFormatStrings.Integer;
                        s.Minimum = short.MinValue;
                        s.Maximum = short.MaxValue;
                    }),
                    new PrimitiveTypeMapper(typeof(ushort), (s) =>
                    {
                        s.Type    = JsonObjectType.Integer;
                        s.Format  = JsonFormatStrings.Integer;
                        s.Minimum = ushort.MinValue;
                        s.Maximum = ushort.MaxValue;
                    }),
                    new PrimitiveTypeMapper(typeof(uint), (s) =>
                    {
                        s.Type    = JsonObjectType.Integer;
                        s.Format  = JsonFormatStrings.Long;
                        s.Minimum = uint.MinValue;
                        s.Maximum = uint.MaxValue;
                    }),
                    new PrimitiveTypeMapper(typeof(ulong), (s) =>
                    {
                        s.Type    = JsonObjectType.Integer;
                        s.Format  = JsonFormatStrings.Long;
                        s.Minimum = ulong.MinValue;
                        s.Maximum = ulong.MaxValue;
                    }),
                    new PrimitiveTypeMapper(typeof(float), (s) =>
                    {
                        s.Type   = JsonObjectType.Number;
                        s.Format = JsonFormatStrings.Float;
                    }),
                    new PrimitiveTypeMapper(typeof(decimal), (s) =>
                    {
                        s.Type   = JsonObjectType.Number;
                        s.Format = JsonFormatStrings.Double;
                    }),
                },
            };

            var schema = JsonSchema.FromType(type, settings);

            schema.Title = null;
            JObject deserializedSchema = JsonConvert.DeserializeObject(schema.ToJson()) as JObject;

            deserializedSchema.Remove("$schema");
            return(deserializedSchema);
        }
Example #11
0
        //订单创建或者更新  因为以前的代码比较凌乱 特做整合与封装  by panhuaguo 2016-8-1
        public string Save()
        {
            string  filedata = Request["filedata"];
            string  action = Request["action"];
            JObject json = (JObject)JsonConvert.DeserializeObject(Request["formdata"]);
            JObject json_user = Extension.Get_UserInfo(HttpContext.User.Identity.Name);
            string  sql = "";
            string  ordercode = string.Empty; bool IsSubmitAfterSave = false;

            if (Request["action"] + "" == "submit")
            {
                json.Remove("STATUS"); json.Remove("SUBMITTIME"); json.Remove("SUBMITUSERNAME"); json.Remove("SUBMITUSERID");
                json.Add("STATUS", 10);
                json.Add("SUBMITTIME", "sysdate");
                json.Add("SUBMITUSERNAME", json_user.Value <string>("REALNAME"));
                json.Add("SUBMITUSERID", json_user.Value <string>("ID"));
            }
            else
            {
                if (string.IsNullOrEmpty(json.Value <string>("SUBMITTIME"))) //有可能提交以后再对部分字段进行修改后保存
                {
                    json.Remove("SUBMITTIME");                               //委托时间  因为该字段需要取ORACLE的时间,而非系统时间 所以需要特殊处理,格式化时并没有加引号
                    json.Add("SUBMITTIME", "null");
                }
                else
                {
                    string submittime = json.Value <string>("SUBMITTIME");
                    json.Remove("SUBMITTIME");//委托时间  因为该字段需要取ORACLE的时间,而非系统时间 所以需要特殊处理
                    json.Add("SUBMITTIME", "to_date('" + submittime + "','yyyy-MM-dd HH24:mi:ss')");
                    IsSubmitAfterSave = true;
                }
            }

            if (json.Value <string>("ENTRUSTTYPE") == "01")
            {
                json.Add("DECLSTATUS", json.Value <string>("STATUS")); json.Add("INSPSTATUS", null);
            }
            if (json.Value <string>("ENTRUSTTYPE") == "02")
            {
                json.Add("DECLSTATUS", null); json.Add("INSPSTATUS", json.Value <string>("STATUS"));
            }
            if (json.Value <string>("ENTRUSTTYPE") == "03")
            {
                json.Add("DECLSTATUS", json.Value <string>("STATUS")); json.Add("INSPSTATUS", json.Value <string>("STATUS"));
            }

            if (string.IsNullOrEmpty(json.Value <string>("CODE")))//新增
            {
                ordercode = Extension.getOrderCode();
                sql       = @"INSERT INTO LIST_ORDER (ID,BUSITYPE,CODE,CUSNO,BUSIUNITCODE,BUSIUNITNAME,CONTRACTNO
                            ,SECONDLADINGBILLNO,ARRIVEDNO,TURNPRENO,GOODSNUM,CLEARANCENO
                            ,LAWFLAG,ENTRUSTTYPE,REPWAYID,CUSTOMAREACODE,REPUNITCODE
                            ,REPUNITNAME,DECLWAY,PORTCODE,INSPUNITCODE,INSPUNITNAME
                            ,ORDERREQUEST,CREATEUSERID,CREATEUSERNAME,STATUS,SUBMITUSERID
                            ,SUBMITUSERNAME,CUSTOMERCODE,CUSTOMERNAME,DECLCARNO,TRADEWAYCODES
                            ,GOODSGW,GOODSNW,PACKKIND,BUSIKIND,ORDERWAY
                            ,CLEARUNIT,CLEARUNITNAME,SHIPNAME,FILGHTNO,GOODSTYPEID
                            ,CONTAINERNO,CREATETIME,SUBMITTIME,SPECIALRELATIONSHIP,PRICEIMPACT,PAYPOYALTIES
                            ,DECLSTATUS,INSPSTATUS,DOCSERVICECODE               
                    ) VALUES (LIST_ORDER_id.Nextval,'{0}','{1}','{2}','{3}','{4}','{5}'
                        ,'{6}','{7}','{8}','{9}','{10}'
                        ,'{11}','{12}','{13}','{14}','{15}'
                        ,'{16}','{17}','{18}','{19}','{20}'
                        ,'{21}','{22}','{23}','{24}','{25}'
                        ,'{26}','{27}','{28}','{29}','{30}'
                        ,'{31}','{32}','{33}','{34}','{35}'
                        ,'{36}','{37}','{38}','{39}','{40}'
                        ,'{41}',sysdate,{42},'{43}','{44}','{45}'
                        ,'{46}','{47}','{48}'
                        )";
                sql       = string.Format(sql, "20", ordercode, json.Value <string>("CUSNO"), json.Value <string>("BUSIUNITCODE"), json.Value <string>("BUSIUNITNAME"), json.Value <string>("CONTRACTNO")
                                          , json.Value <string>("SECONDLADINGBILLNO"), json.Value <string>("ARRIVEDNO"), json.Value <string>("TURNPRENO"), json.Value <string>("GOODSNUM"), json.Value <string>("CLEARANCENO")
                                          , GetChk(json.Value <string>("LAWFLAG")), json.Value <string>("ENTRUSTTYPE"), json.Value <string>("REPWAYID"), json.Value <string>("CUSTOMAREACODE"), GetCode(json.Value <string>("REPUNITCODE"))
                                          , GetName(json.Value <string>("REPUNITCODE")), json.Value <string>("DECLWAY"), json.Value <string>("PORTCODE"), GetCode(json.Value <string>("INSPUNITCODE")), GetName(json.Value <string>("INSPUNITCODE"))
                                          , json.Value <string>("ORDERREQUEST"), json_user.Value <string>("ID"), json_user.Value <string>("REALNAME"), json.Value <string>("STATUS"), json.Value <string>("SUBMITUSERID")
                                          , json.Value <string>("SUBMITUSERNAME"), json_user.Value <string>("CUSTOMERCODE"), json_user.Value <string>("CUSTOMERNAME"), json.Value <string>("DECLCARNO"), json.Value <string>("TRADEWAYCODES")
                                          , json.Value <string>("GOODSGW"), json.Value <string>("GOODSNW"), json.Value <string>("PACKKIND"), "001", "1"
                                          , json_user.Value <string>("CUSTOMERCODE"), json_user.Value <string>("CUSTOMERNAME"), json.Value <string>("SHIPNAME"), json.Value <string>("FILGHTNO"), json.Value <string>("GOODSTYPEID")
                                          , json.Value <string>("CONTAINERNO"), json.Value <string>("SUBMITTIME"), GetChk(json.Value <string>("SPECIALRELATIONSHIP")), GetChk(json.Value <string>("PRICEIMPACT")), GetChk(json.Value <string>("PAYPOYALTIES"))
                                          , json.Value <string>("DECLSTATUS"), json.Value <string>("INSPSTATUS"), json.Value <string>("DOCSERVICECODE")
                                          );
            }
            else//修改
            {
                ordercode = json.Value <string>("CODE");

                /*sql = @"UPDATE LIST_ORDER
                 *       SET BUSITYPE='{1}',CUSNO='{2}',BUSIUNITCODE='{3}',BUSIUNITNAME='{4}',CONTRACTNO='{5}'
                 *          ,SECONDLADINGBILLNO='{6}',ARRIVEDNO='{7}',TURNPRENO='{8}',GOODSNUM='{9}',CLEARANCENO='{10}'
                 *          ,LAWFLAG='{11}',ENTRUSTTYPE='{12}',REPWAYID='{13}',CUSTOMAREACODE='{14}',REPUNITCODE='{15}'
                 *          ,REPUNITNAME='{16}',DECLWAY='{17}',PORTCODE='{18}',INSPUNITCODE='{19}',INSPUNITNAME='{20}'
                 *          ,ORDERREQUEST='{21}',STATUS='{22}',SUBMITUSERID='{23}',SUBMITUSERNAME='******',CUSTOMERCODE='{25}'
                 *          ,CUSTOMERNAME='{26}',DECLCARNO='{27}',TRADEWAYCODES='{28}',SUBMITTIME={29},GOODSGW='{30}'
                 *          ,GOODSNW='{31}',PACKKIND='{32}',BUSIKIND='{33}',ORDERWAY='{34}',CLEARUNIT='{35}'
                 *          ,CLEARUNITNAME='{36}',SHIPNAME='{37}',FILGHTNO='{38}',GOODSTYPEID='{39}',CONTAINERNO='{40}'
                 *          ,SPECIALRELATIONSHIP='{41}',PRICEIMPACT='{42}', PAYPOYALTIES='{43}',DOCSERVICECODE='{44}'
                 *          ";
                 *
                 * if (IsSubmitAfterSave == false)//提交之后保存,就不更新报关报检状态;
                 * {
                 *  sql += @",DECLSTATUS='{45}',INSPSTATUS='{46}'";
                 * }
                 * sql += @" WHERE CODE = '{0}'";
                 */
                string allcol = @"CODE
                                ,BUSITYPE,CUSNO,BUSIUNITCODE,BUSIUNITNAME,CONTRACTNO 
                                ,SECONDLADINGBILLNO,ARRIVEDNO,TURNPRENO,GOODSNUM,CLEARANCENO 
                                ,LAWFLAG,ENTRUSTTYPE,REPWAYID,CUSTOMAREACODE,REPUNITCODE 
                                ,REPUNITNAME,DECLWAY,PORTCODE,INSPUNITCODE,INSPUNITNAME 
                                ,ORDERREQUEST,STATUS,SUBMITUSERID,SUBMITUSERNAME,CUSTOMERCODE
                                ,CUSTOMERNAME,DECLCARNO,TRADEWAYCODES,SUBMITTIME,GOODSGW 
                                ,GOODSNW,PACKKIND,BUSIKIND,ORDERWAY,CLEARUNIT 
                                ,CLEARUNITNAME,SHIPNAME,FILGHTNO,GOODSTYPEID,CONTAINERNO 
                                ,SPECIALRELATIONSHIP,PRICEIMPACT, PAYPOYALTIES,DOCSERVICECODE,DECLSTATUS 
                                ,INSPSTATUS
                                ";
                sql = Extension.getUpdateSql(allcol, ordercode, IsSubmitAfterSave);
                if (sql != "")
                {
                    sql = string.Format(sql, json.Value <string>("CODE"), "20", json.Value <string>("CUSNO"), json.Value <string>("BUSIUNITCODE"), json.Value <string>("BUSIUNITNAME"), json.Value <string>("CONTRACTNO")
                                        , json.Value <string>("SECONDLADINGBILLNO"), json.Value <string>("ARRIVEDNO"), json.Value <string>("TURNPRENO"), json.Value <string>("GOODSNUM"), json.Value <string>("CLEARANCENO")
                                        , GetChk(json.Value <string>("LAWFLAG")), json.Value <string>("ENTRUSTTYPE"), json.Value <string>("REPWAYID"), json.Value <string>("CUSTOMAREACODE"), GetCode(json.Value <string>("REPUNITCODE"))
                                        , GetName(json.Value <string>("REPUNITCODE")), json.Value <string>("DECLWAY"), json.Value <string>("PORTCODE"), GetCode(json.Value <string>("INSPUNITCODE")), GetName(json.Value <string>("INSPUNITCODE"))
                                        , json.Value <string>("ORDERREQUEST"), json.Value <string>("STATUS"), json.Value <string>("SUBMITUSERID"), json.Value <string>("SUBMITUSERNAME"), json_user.Value <string>("CUSTOMERCODE")
                                        , json_user.Value <string>("CUSTOMERNAME"), json.Value <string>("DECLCARNO"), json.Value <string>("TRADEWAYCODES"), json.Value <string>("SUBMITTIME"), json.Value <string>("GOODSGW")
                                        , json.Value <string>("GOODSNW"), json.Value <string>("PACKKIND"), "001", "1", json_user.Value <string>("CUSTOMERCODE")
                                        , json_user.Value <string>("CUSTOMERNAME"), json.Value <string>("SHIPNAME"), json.Value <string>("FILGHTNO"), json.Value <string>("GOODSTYPEID"), json.Value <string>("CONTAINERNO")
                                        , GetChk(json.Value <string>("SPECIALRELATIONSHIP")), GetChk(json.Value <string>("PRICEIMPACT")), GetChk(json.Value <string>("PAYPOYALTIES"))
                                        , json.Value <string>("DOCSERVICECODE"), json.Value <string>("DECLSTATUS"), json.Value <string>("INSPSTATUS")
                                        );
                }
            }
            int result = DBMgr.ExecuteNonQuery(sql);

            if (result == 1)
            {
                //集装箱及报关车号列表更新
                Extension.predeclcontainer_update(ordercode, json.Value <string>("CONTAINERTRUCK"));

                //更新随附文件
                Extension.Update_Attachment(ordercode, filedata, json.Value <string>("ORIGINALFILEIDS"), json_user);

                //插入订单状态变更日志
                Extension.add_list_time(json.Value <Int32>("STATUS"), ordercode, json_user);
                if (json.Value <Int32>("STATUS") > 10)
                {
                    Extension.Insert_FieldUpdate_History(ordercode, json, json_user, "20");
                }
                return("{success:true,ordercode:'" + ordercode + "'}");
            }
            else
            {
                return("{success:false}");
            }
        }
Example #12
0
        public ActionResult Index(string ym = "")
        {
            ViewBag.Title = "個人薪資查詢";
            if (string.IsNullOrEmpty(ym))
            {
                ModelState.AddModelError("", "請輸入年度與月份");
                return(View());
            }
            var ctx  = new ApplicationDbContext();
            var user = ctx.Users.Where(x => x.UserName == User.Identity.Name).FirstOrDefault();

            if (user != null)
            {
                string   workNo = user.workNo;
                int      y      = Convert.ToInt32(ym.Split('-')[0]);
                int      m      = Convert.ToInt32(ym.Split('-')[1]);
                DateTime dtym   = new DateTime(y, m, 1);
                ViewBag.ym = dtym.ToString("yyyy-MM");
                salary sObj = ctx.salaryList.Where(x => x.year == y && x.month == m && x.workNo == user.workNo).FirstOrDefault();
                if (sObj != null)
                {
                    JObject jobj = null;
                    try
                    {
                        jobj = JObject.Parse(sObj.jData);
                        List <string> removeList = new List <string>();
                        foreach (JProperty prop in jobj.Properties())
                        {
                            if (getHiddenFields().Where(x => prop.Name.Contains(x)).Count() > 0)
                            {
                                if (getShowFields().Where(x => prop.Name.Equals(x)).Count() == 0)
                                {
                                    removeList.Add(prop.Name);
                                }
                            }
                        }
                        foreach (string propName in removeList)
                        {
                            jobj.Remove(propName);
                        }
                    }
                    catch (Exception ex)
                    {
                        jobj = null;
                    }
                    if (jobj == null)
                    {
                        return(View());
                    }
                    DataTable dt = new DataTable();

                    List <KeyValuePair <string, int> > fdList = new List <KeyValuePair <string, int> >();

                    for (int i = 0; i < jobj.Properties().ToList <JProperty>().Count(); i++)
                    {
                        string pnm  = jobj.Properties().ToList <JProperty>()[i].Name;
                        string pnm2 = "";
                        if (pnm.Split('-').Count() > 1)
                        {
                            pnm = pnm.Split('-')[0];
                        }
                        KeyValuePair <string, int> fd;
                        if (fdList.Where(x => x.Key == pnm).Count() > 0)
                        {
                            int idx = 0;
                            for (int itmp = 0; itmp < fdList.Count(); itmp++)
                            {
                                if (fdList[itmp].Key == pnm)
                                {
                                    fd           = fdList.Where(x => x.Key == pnm).First();
                                    fd           = new KeyValuePair <string, int>(pnm, fd.Value + 1);
                                    fdList[itmp] = fd;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            fd = new KeyValuePair <string, int>(pnm, 1);
                            fdList.Add(fd);
                        }
                        dt.Columns.Add(jobj.Properties().ToList <JProperty>()[i].Name);
                    }

                    DataRow r = dt.NewRow();
                    for (int i = 0; i < jobj.Properties().ToList <JProperty>().Count(); i++)
                    {
                        string pnm = jobj.Properties().ToList <JProperty>()[i].Name;
                        r[pnm] = jobj[pnm];
                    }
                    dt.Rows.Add(r);
                    dt.AcceptChanges();
                    ViewBag.data   = dt;
                    ViewBag.fdList = fdList;
                    return(View());
                }
            }

            return(View());
        }
Example #13
0
        public static void ApplyVersions(JObject json, AvcVersion avc)
        {
            // Get the minimum and maximum KSP versions that already exist in the metadata.
            // Use specific KSP version if min/max don't exist.
            var existingKspMinStr = (string)json["ksp_version_min"] ?? (string)json["ksp_version"];
            var existingKspMaxStr = (string)json["ksp_version_max"] ?? (string)json["ksp_version"];

            var existingKspMin = existingKspMinStr == null ? null : KspVersion.Parse(existingKspMinStr);
            var existingKspMax = existingKspMaxStr == null ? null : KspVersion.Parse(existingKspMaxStr);

            // Get the minimum and maximum KSP versions that are in the AVC file.
            // http://ksp.cybutek.net/kspavc/Documents/README.htm
            // KSP-AVC allows (requires?) KSP_VERSION to be set
            // when KSP_VERSION_MIN/_MAX are set, but CKAN treats
            // its equivalent properties as mutually exclusive.
            // Only fallback if neither min nor max are defined,
            // for open ranges.
            KspVersion avcKspMin, avcKspMax;

            if (avc.ksp_version_min == null && avc.ksp_version_max == null)
            {
                // Use specific KSP version if min/max don't exist
                avcKspMin = avcKspMax = avc.ksp_version;
            }
            else
            {
                avcKspMin = avc.ksp_version_min;
                avcKspMax = avc.ksp_version_max;
            }

            // Now calculate the minimum and maximum KSP versions between both the existing metadata and the
            // AVC file.
            var kspMins  = new List <KspVersion>();
            var kspMaxes = new List <KspVersion>();

            if (!KspVersion.IsNullOrAny(existingKspMin))
            {
                kspMins.Add(existingKspMin);
            }

            if (!KspVersion.IsNullOrAny(avcKspMin))
            {
                kspMins.Add(avcKspMin);
            }

            if (!KspVersion.IsNullOrAny(existingKspMax))
            {
                kspMaxes.Add(existingKspMax);
            }

            if (!KspVersion.IsNullOrAny(avcKspMax))
            {
                kspMaxes.Add(avcKspMax);
            }

            var kspMin = kspMins.Any()  ? kspMins.Min()  : null;
            var kspMax = kspMaxes.Any() ? kspMaxes.Max() : null;

            if (kspMin != null || kspMax != null)
            {
                // If we have either a minimum or maximum KSP version, remove all existing KSP version
                // information from the metadata.
                json.Remove("ksp_version");
                json.Remove("ksp_version_min");
                json.Remove("ksp_version_max");

                if (kspMin != null && kspMax != null)
                {
                    // If we have both a minimum and maximum KSP version...
                    if (kspMin.CompareTo(kspMax) == 0)
                    {
                        // ...and they are equal, then just set ksp_version
                        json["ksp_version"] = kspMin.ToString();
                    }
                    else
                    {
                        // ...otherwise set both ksp_version_min and ksp_version_max
                        json["ksp_version_min"] = kspMin.ToString();
                        json["ksp_version_max"] = kspMax.ToString();
                    }
                }
                else
                {
                    // If we have only one or the other then set which ever is applicable

                    if (kspMin != null)
                    {
                        json["ksp_version_min"] = kspMin.ToString();
                    }

                    if (kspMax != null)
                    {
                        json["ksp_version_max"] = kspMax.ToString();
                    }
                }
            }

            if (avc.version != null)
            {
                // In practice, the version specified in .version files tends to be unreliable, with authors
                // forgetting to update it when new versions are released. Therefore if we have a version
                // specified from another source such as SpaceDock, curse or a GitHub tag, don't overwrite it
                // unless x_netkan_trust_version_file is true.
                if ((bool?)json["x_netkan_trust_version_file"] ?? false)
                {
                    json.Remove("version");
                }
                json.SafeAdd("version", avc.version.ToString());
            }
        }