Exemplo n.º 1
0
        public static SerialNumberType CreateSerialNumberType(int ID, string name)
        {
            SerialNumberType serialNumberType = new SerialNumberType();

            serialNumberType.Id   = ID;
            serialNumberType.Name = name;
            return(serialNumberType);
        }
Exemplo n.º 2
0
 public ActionResult Edit(SerialNumberType obj)
 {
     try
     {
         NSession.Update(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return(Json(new { IsSuccess = false, ErrorMsg = "出错了" }));
     }
     return(Json(new { IsSuccess = true }));
 }
Exemplo n.º 3
0
        /// <summary>
        /// 根据Id获取
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public SerialNumberType GetById(int Id)
        {
            SerialNumberType obj = NSession.Get <SerialNumberType>(Id);

            if (obj == null)
            {
                throw new Exception("返回实体为空");
            }
            else
            {
                return(obj);
            }
        }
Exemplo n.º 4
0
 public JsonResult DeleteConfirmed(int id)
 {
     try
     {
         SerialNumberType obj = GetById(id);
         NSession.Delete(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return(Json(new { IsSuccess = false, ErrorMsg = "出错了" }));
     }
     return(Json(new { IsSuccess = true }));
 }
    public static SerialNumber CreateComponent(SerialNumber where, EdgeworkConfiguration config)
    {
        SerialNumberType sntype = config == null ? SerialNumberType.RANDOM_NORMAL : config.SerialNumberType;
        string           sn     = config == null ? string.Empty : config.CustomSerialNumber;

        SerialNumber widget = Instantiate(where);

        if (string.IsNullOrEmpty(sn) && sntype == SerialNumberType.CUSTOM)
        {
            sntype = SerialNumberType.RANDOM_NORMAL;
        }

        if (sntype == SerialNumberType.RANDOM_NORMAL)
        {
            string str1 = string.Empty;
            for (int index = 0; index < 2; ++index)
            {
                str1 = str1 + SerialNumberPossibleCharArray[Random.Range(0, SerialNumberPossibleCharArray.Length)];
            }
            string str2 = str1 + (object)Random.Range(0, 10);
            for (int index = 3; index < 5; ++index)
            {
                str2 = str2 + SerialNumberPossibleCharArray[Random.Range(0, SerialNumberPossibleCharArray.Length - 10)];
            }
            widget.serial = str2 + Random.Range(0, 10);
        }
        else if (sntype == SerialNumberType.RANDOM_ANY)
        {
            string res = string.Empty;
            for (int index = 0; index < 6; ++index)
            {
                res = res + SerialNumberPossibleCharArray[Random.Range(0, SerialNumberPossibleCharArray.Length)];
            }
            widget.serial = res;
        }
        else
        {
            widget.serial = sn;
        }

        widget.serialTextMesh.text = widget.serial;

        Debug.Log("Serial: " + widget.serial);
        return(widget);
    }
        public override void OnInspectorGUI()
        {
            if (target != null)
            {
                serializedObject.Update();

                SerialNumberType serialNumberType = DrawSerialNumberTypePicker();
                if (serialNumberType == SerialNumberType.CUSTOM)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("CustomSerialNumber"));
                }

                EdgeworkConfiguration config = (EdgeworkConfiguration)serializedObject.targetObject;
                if (config != null && config.Widgets.Any(x => x.Type == WidgetType.TWOFACTOR))
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("TwoFactorResetTime"));
                }

                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("Widgets:");

                SerializedProperty widgetListProperty = serializedObject.FindProperty("Widgets");
                EditorGUI.indentLevel++;
                for (int i = 0; i < widgetListProperty.arraySize; i++)
                {
                    DrawWidget(widgetListProperty, i);
                    EditorGUILayout.Space();
                }
                EditorGUI.indentLevel--;

                EditorGUILayout.Separator();
                EditorGUILayout.Separator();
                EditorGUILayout.Separator();

                if (GUILayout.Button("Add Widget"))
                {
                    AddWidget();
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 7
0
        public override void OnInspectorGUI()
        {
            if (target != null)
            {
                serializedObject.Update();

                SerialNumberType serialNumberType = DrawSerialNumberTypePicker();
                if (serialNumberType == SerialNumberType.CUSTOM)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("CustomSerialNumber"));
                }

                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("Widgets:");

                SerializedProperty widgetListProperty = serializedObject.FindProperty("Widgets");
                EditorGUI.indentLevel++;
                for (int i = 0; i < widgetListProperty.arraySize; i++)
                {
                    DrawWidget(widgetListProperty, i);
                    EditorGUILayout.Space();
                }
                EditorGUI.indentLevel--;

                EditorGUILayout.Separator();
                EditorGUILayout.Separator();
                EditorGUILayout.Separator();

                if (GUILayout.Button("Add Widget"))
                {
                    AddWidget();
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 8
0
        public ActionResult Edit(int id)
        {
            SerialNumberType obj = GetById(id);

            return(View(obj));
        }
Exemplo n.º 9
0
 public void AddToSerialNumberTypes(SerialNumberType serialNumberType)
 {
     base.AddObject("SerialNumberTypes", serialNumberType);
 }