示例#1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc((MvcOptions options) =>
            {
                options.Filters.Add(new ProducesAttribute("application/json"));

                // HACK We need to disable EndpointRouting in order to run properly in 3.1
                System.Reflection.PropertyInfo prop = options.GetType().GetProperty("EnableEndpointRouting");
                prop?.SetValue(options, false);
            }).SetCompatibilityVersion(CompatibilityVersion.Latest);

            services.Configure <GzipCompressionProviderOptions>(options =>
            {
                options.Level = CompressionLevel.Optimal;
            });

            services.AddResponseCompression(configureOptions =>
            {
                configureOptions.Providers.Add <GzipCompressionProvider>();
                configureOptions.MimeTypes = new List <string> {
                    "application/octet-stream"
                };
            });

            var config = new PrometheusConfiguration();

            Configuration.Bind(nameof(PrometheusConfiguration), config);
            if (config.Enabled)
            {
                services.AddSingleton <MetricsStoreService>();
                services.AddHostedService <MetricsService>();
            }
        }
        private HttpWebResponse CreateMockedHttpWebResponse(int statusCode, string content, string[] headerNames, string[] headerValues)
        {
            byte[] contentBytes   = Encoding.UTF8.GetBytes(content);
            Stream responseStream = new MemoryStream();

            responseStream.Write(contentBytes, 0, contentBytes.Length);
            responseStream.Seek(0, SeekOrigin.Begin);

            WebHeaderCollection h = new WebHeaderCollection();

            if (headerNames != null)
            {
                for (int i = 0; i < headerNames.Length; i++)
                {
                    h.Add(headerNames[i], headerValues[i]);
                }
            }

            HttpWebResponse oNewResponse = (System.Net.HttpWebResponse)System.Activator.CreateInstance(typeof(HttpWebResponse));

            System.Reflection.PropertyInfo oInfo = oNewResponse.GetType().GetProperty("ResponseStream",
                                                                                      System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.FlattenHierarchy);
            oInfo?.SetValue(oNewResponse, responseStream);
            System.Reflection.FieldInfo oFInfo = oNewResponse.GetType().GetField("m_HttpResponseHeaders",
                                                                                 System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.FlattenHierarchy);
            oFInfo?.SetValue(oNewResponse, h);
            oFInfo = oNewResponse.GetType().GetField("m_StatusCode",
                                                     System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.FlattenHierarchy);
            oFInfo?.SetValue(oNewResponse, statusCode);


            return(oNewResponse);
        }
示例#3
0
 /// <summary>
 /// Set the value of a specific Property
 /// </summary>
 /// <param name="item"></param>
 /// <param name="propertyName"></param>
 /// <param name="propertyValue"></param>
 public static void SetPropertyValue(this object item, string propertyName, object propertyValue)
 {
     if (item != null)
     {
         System.Reflection.PropertyInfo?propertyInfo = item.GetType().GetProperty(propertyName);
         propertyInfo?.SetValue(item, propertyValue);
     }
 }
示例#4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc((MvcOptions options) =>
            {
                // HACK We need to disable EndpointRouting in order to run properly in 3.1
                System.Reflection.PropertyInfo prop = options.GetType().GetProperty("EnableEndpointRouting");
                prop?.SetValue(options, false);
            }).SetCompatibilityVersion(CompatibilityVersion.Latest);

            services.Configure <GzipCompressionProviderOptions>(options =>
            {
                options.Level = CompressionLevel.Optimal;
            });

            services.AddResponseCompression(configureOptions =>
            {
                configureOptions.Providers.Add <GzipCompressionProvider>();
                configureOptions.MimeTypes = new List <string> {
                    "application/octet-stream"
                };
            });
        }
        public virtual void Modify(ref ValidationErrors errors, Apps.Models.SCV.AR.AR_DOWNLOAD_SHIPMENT_DETAIL_MODEL model, params string[] updateProperties)
        {
            Apps.Models.AR_DOWNLOAD_SHIPMENT_DETAIL entity = m_Rep.GetById(model.INTERFACE_RECORD_ID);
            if (entity == null)
            {
                errors.Add(Resource.Disable);
                return;
            }
            if (updateProperties.Count() <= 0)
            {
                entity.INTERFACE_RECORD_ID   = model.INTERFACE_RECORD_ID;
                entity.INTERFACE_LINK_ID     = model.INTERFACE_LINK_ID;
                entity.INTERFACE_ACTION_CODE = model.INTERFACE_ACTION_CODE;
                entity.INTERFACE_CONDITION   = model.INTERFACE_CONDITION;
                entity.PROCESS_STAMP         = model.PROCESS_STAMP;
                entity.WAREHOUSE             = model.WAREHOUSE;
                entity.COMPANY            = model.COMPANY;
                entity.SHIPMENT_ID        = model.SHIPMENT_ID;
                entity.ERP_ORDER          = model.ERP_ORDER;
                entity.ERP_ORDER_LINE_NUM = model.ERP_ORDER_LINE_NUM;
                entity.SHIPMENT_TYPE      = model.SHIPMENT_TYPE;
                entity.ITEM                      = model.ITEM;
                entity.ITEM_DESC                 = model.ITEM_DESC;
                entity.TOTAL_QTY                 = model.TOTAL_QTY;
                entity.REQUEST_QTY               = model.REQUEST_QTY;
                entity.QUANTITY_UM               = model.QUANTITY_UM;
                entity.ALLOCATION_RULE           = model.ALLOCATION_RULE;
                entity.PICK_LOC                  = model.PICK_LOC;
                entity.USER_STAMP                = model.USER_STAMP;
                entity.DATE_TIME_STAMP           = model.DATE_TIME_STAMP;
                entity.ATTRIBUTE_TRACK           = model.ATTRIBUTE_TRACK;
                entity.ATTRIBUTE1                = model.ATTRIBUTE1;
                entity.ATTRIBUTE2                = model.ATTRIBUTE2;
                entity.ATTRIBUTE3                = model.ATTRIBUTE3;
                entity.ATTRIBUTE4                = model.ATTRIBUTE4;
                entity.ATTRIBUTE5                = model.ATTRIBUTE5;
                entity.ATTRIBUTE6                = model.ATTRIBUTE6;
                entity.ATTRIBUTE7                = model.ATTRIBUTE7;
                entity.ATTRIBUTE8                = model.ATTRIBUTE8;
                entity.INVENTORY_STS             = model.INVENTORY_STS;
                entity.DOCK_LOC                  = model.DOCK_LOC;
                entity.PACKING_CLASS             = model.PACKING_CLASS;
                entity.STATUS                    = model.STATUS;
                entity.INTERNAL_WAVE_NUM         = model.INTERNAL_WAVE_NUM;
                entity.TOTAL_WEIGHT              = model.TOTAL_WEIGHT;
                entity.WEIGHT_UM                 = model.WEIGHT_UM;
                entity.TOTAL_VOLUME              = model.TOTAL_VOLUME;
                entity.VOLUME_UM                 = model.VOLUME_UM;
                entity.BACK_ORDER_LINE_NUM       = model.BACK_ORDER_LINE_NUM;
                entity.USER_DEF1                 = model.USER_DEF1;
                entity.USER_DEF2                 = model.USER_DEF2;
                entity.USER_DEF3                 = model.USER_DEF3;
                entity.USER_DEF4                 = model.USER_DEF4;
                entity.USER_DEF5                 = model.USER_DEF5;
                entity.USER_DEF6                 = model.USER_DEF6;
                entity.USER_DEF7                 = model.USER_DEF7;
                entity.USER_DEF8                 = model.USER_DEF8;
                entity.ITEM_LIST_PRICE           = model.ITEM_LIST_PRICE;
                entity.ITEM_NET_PRICE            = model.ITEM_NET_PRICE;
                entity.USER_DEF9                 = model.USER_DEF9;
                entity.USER_DEF10                = model.USER_DEF10;
                entity.SERIAL_NUM_TRACK          = model.SERIAL_NUM_TRACK;
                entity.ORIGINAL_ORDER_NUM        = model.ORIGINAL_ORDER_NUM;
                entity.CREATE_DATE_TIME          = model.CREATE_DATE_TIME;
                entity.CREATE_USER               = model.CREATE_USER;
                entity.HOST_ITEM                 = model.HOST_ITEM;
                entity.UPLOAD_INTERFACE_REQUIRED = model.UPLOAD_INTERFACE_REQUIRED;
            }
            else
            {
                Type type  = typeof(Apps.Models.SCV.AR.AR_DOWNLOAD_SHIPMENT_DETAIL_MODEL);
                Type typeE = typeof(Apps.Models.AR_DOWNLOAD_SHIPMENT_DETAIL);
                foreach (var item in updateProperties)
                {
                    System.Reflection.PropertyInfo pi  = type.GetProperty(item);
                    System.Reflection.PropertyInfo piE = typeE.GetProperty(item);
                    piE.SetValue(entity, pi.GetValue(model), null);
                }
            }


            m_Rep.Modify(entity, updateProperties);
        }
 public static void enableDoubleBuff(System.Windows.Forms.Control cont)
 {
     System.Reflection.PropertyInfo DemoProp = typeof(System.Windows.Forms.Control).GetProperty("DoubleBuffered", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
     DemoProp.SetValue(cont, true, null);
 }
        //***************************************************************************
        // Static Methods
        //
        /// <summary>
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="itemData"></param>
        /// <returns></returns>
        public static T FromSerializedData <T>(string itemData)
            where T : SerializableItem, new()
        {
            // Did you read the "GetSerialized" method comments?  This is worse. Hold onto your butts...

            // Create a new instance of whatever SerializableItem class "T" is.
            T newItem = new T();

            // Get the Type reference for "T".  We'll use it in a minute.
            Type classType = typeof(T);

            // Start splitting the data.  Each distint set of values are seperated by a comma.
            string[] vals = itemData.Split(',');

            // We want to set these three values at the very end, to make sure they don't get altered by mistake.
            bool isNew  = false,
                 isEdit = false,
                 isDel  = false;

            // Loop through the pieces.
            for (int i = 0; i < vals.Length; i++)
            {
                // The key/value pairs of data are seperated by a colon.
                string[] pcs = vals[i].Split(':');
                if (pcs.Length != 2)
                {
                    throw new SerializationException("Unexpected serialization data format.");
                }

                // Check for one of our three specially-handled values.
                if (pcs[0] == "IsEdited")
                {
                    isEdit = bool.Parse(pcs[1]); continue;
                }
                else if (pcs[0] == "IsNew")
                {
                    isNew = bool.Parse(pcs[1]); continue;
                }
                else if (pcs[0] == "IsDeleted")
                {
                    isDel = bool.Parse(pcs[1]); continue;
                }

                // Now, we're going to look for a property with the same name as our key.
                System.Reflection.PropertyInfo prop = classType.GetProperty(pcs[0], ReflectionSetBindingFlags);
                if (prop == null)
                {
                    throw new Exception("Unable to location class member reference in serialized data.");
                }

                // Now, we get to determine exactly how we're going to deserialize the data.
                object setValue = null;
                try
                {
                    if (prop.Name.ToLower() == "parent")
                    {
                        setValue = newItem;
                    }
                    else if (prop.PropertyType.IsAssignableFrom(typeof(SerializableItem)))
                    {
                        System.Reflection.MethodInfo getFromSerializedMethod = prop.PropertyType.GetMethod("FromSerializedData"
                                                                                                           , System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.FlattenHierarchy
                                                                                                           , null
                                                                                                           , new Type[] { typeof(System.String) }
                                                                                                           , null);

                        if (getFromSerializedMethod == null)
                        {
                            throw new Exception("Unable to determine method to get new item from serialized data.");
                        }

                        // This takes the method we found a few lines up, and constructs a generic call with the property's
                        //   data type attached.  This is the MethodInfo we'll actually invoke to call the method.
                        System.Reflection.MethodInfo genericMethodCall = getFromSerializedMethod.MakeGenericMethod(prop.PropertyType);

                        // This should call this same method for the Type of the specified property.
                        setValue = genericMethodCall.Invoke(null, new object[] { pcs[1] });
                    }
                    else if (prop.PropertyType.IsAssignableFrom(typeof(SerializableCollection <>)))
                    {
                        // This is a serialized collection.  We need to create a new instance of the type and call its "DeserializeCollection" method.
                        var col = Activator.CreateInstance(prop.PropertyType);
                        (col as ISerializableCollection).DeserializeCollection(pcs[1]);
                        setValue = col;
                    }
                    else
                    {
                        switch (prop.PropertyType.Name.ToLower())
                        {
                        case "int32":
                            setValue = int.Parse(pcs[1]);
                            break;

                        case "boolean":
                            setValue = bool.Parse(pcs[1]);
                            break;

                        case "double":
                            setValue = double.Parse(pcs[1]);
                            break;

                        case "decimal":
                            setValue = decimal.Parse(pcs[1]);
                            break;

                        case "string":
                            // For string values, we stored a hexidecimal string of their UTF8 encoding.
                            setValue = System.Text.Encoding.UTF8.GetString(Hex.GetBytes(pcs[1]));
                            break;

                        default:
                            throw new Exception("Unhandled data type: " + prop.PropertyType.Name);
                        }
                    }
                }
                catch (Exception ex)
                { throw new Exception("Unable to convert serialized value to property's data type.", ex); }

                prop.SetValue(newItem, setValue, null);
            }

            newItem.IsEdited  = isEdit;
            newItem.IsNew     = isNew;
            newItem.IsDeleted = isDel;
            return(newItem);
        }
示例#8
0
 void set_new_id(D document)
 {
     System.Reflection.PropertyInfo pi = typeof(D).GetProperty("ID");
     pi.SetValue(document, DateTime.Now.Ticks);
 }
        public virtual void Modify(ref ValidationErrors errors, Apps.Models.SCV.SHIPMENT.SHIPMENT_ALLOC_REQUEST_MODEL model, params string[] updateProperties)
        {
            Apps.Models.SHIPMENT_ALLOC_REQUEST entity = m_Rep.GetById(model.INTERNAL_SHIP_ALLOC_NUM);
            if (entity == null)
            {
                errors.Add(Resource.Disable);
                return;
            }
            if (updateProperties.Count() <= 0)
            {
                entity.INTERNAL_SHIP_ALLOC_NUM    = model.INTERNAL_SHIP_ALLOC_NUM;
                entity.INTERNAL_SHIPMENT_LINE_NUM = model.INTERNAL_SHIPMENT_LINE_NUM;
                entity.INTERNAL_SHIPMENT_NUM      = model.INTERNAL_SHIPMENT_NUM;
                entity.SHIPMENT_ID         = model.SHIPMENT_ID;
                entity.SHIPMENT_TYPE       = model.SHIPMENT_TYPE;
                entity.PRIORITY            = model.PRIORITY;
                entity.WAREHOUSE           = model.WAREHOUSE;
                entity.ITEM                = model.ITEM;
                entity.COMPANY             = model.COMPANY;
                entity.ITEM_DESC           = model.ITEM_DESC;
                entity.REQUESTED_QTY       = model.REQUESTED_QTY;
                entity.ALLOCATED_QTY       = model.ALLOCATED_QTY;
                entity.QUANTITY_UM         = model.QUANTITY_UM;
                entity.ATTRIBUTE_NUM       = model.ATTRIBUTE_NUM;
                entity.FROM_LOC            = model.FROM_LOC;
                entity.TO_LOC              = model.TO_LOC;
                entity.FROM_ZONE           = model.FROM_ZONE;
                entity.TO_ZONE             = model.TO_ZONE;
                entity.FROM_LPN            = model.FROM_LPN;
                entity.FROM_PARENT_LPN     = model.FROM_PARENT_LPN;
                entity.CUSTOMER            = model.CUSTOMER;
                entity.SHIP_TO             = model.SHIP_TO;
                entity.INTERNAL_WAVE_NUM   = model.INTERNAL_WAVE_NUM;
                entity.PACKING_CLASS       = model.PACKING_CLASS;
                entity.USER_DEF1           = model.USER_DEF1;
                entity.USER_DEF2           = model.USER_DEF2;
                entity.USER_DEF3           = model.USER_DEF3;
                entity.USER_DEF4           = model.USER_DEF4;
                entity.USER_DEF5           = model.USER_DEF5;
                entity.USER_DEF6           = model.USER_DEF6;
                entity.USER_DEF7           = model.USER_DEF7;
                entity.USER_DEF8           = model.USER_DEF8;
                entity.USER_STAMP          = model.USER_STAMP;
                entity.DATE_TIME_STAMP     = model.DATE_TIME_STAMP;
                entity.CONVERTED_ALLOC_QTY = model.CONVERTED_ALLOC_QTY;
                entity.CONVERTED_QTY_UM    = model.CONVERTED_QTY_UM;
                entity.FROM_TEMPL_FIELD1   = model.FROM_TEMPL_FIELD1;
                entity.FROM_TEMPL_FIELD2   = model.FROM_TEMPL_FIELD2;
                entity.FROM_TEMPL_FIELD3   = model.FROM_TEMPL_FIELD3;
                entity.FROM_TEMPL_FIELD4   = model.FROM_TEMPL_FIELD4;
                entity.FROM_TEMPL_FIELD5   = model.FROM_TEMPL_FIELD5;
                entity.TO_TEMPL_FIELD1     = model.TO_TEMPL_FIELD1;
                entity.TO_TEMPL_FIELD2     = model.TO_TEMPL_FIELD2;
                entity.TO_TEMPL_FIELD3     = model.TO_TEMPL_FIELD3;
                entity.TO_TEMPL_FIELD4     = model.TO_TEMPL_FIELD4;
                entity.TO_TEMPL_FIELD5     = model.TO_TEMPL_FIELD5;
                entity.TASK_CREATED        = model.TASK_CREATED;
                entity.TREAT_AS_LOOSE      = model.TREAT_AS_LOOSE;
                entity.INVENTORY_STS       = model.INVENTORY_STS;
                entity.REPLENISHMENT_REQD  = model.REPLENISHMENT_REQD;
                entity.CONTAINER_WEIGHT    = model.CONTAINER_WEIGHT;
                entity.CONTAINER_HEIGHT    = model.CONTAINER_HEIGHT;
                entity.CONTAINER_WIDTH     = model.CONTAINER_WIDTH;
                entity.CONTAINER_LENGTH    = model.CONTAINER_LENGTH;
                entity.DIMENSION_UM        = model.DIMENSION_UM;
                entity.WEIGHT_UM           = model.WEIGHT_UM;
                entity.ITEM_LENGTH         = model.ITEM_LENGTH;
                entity.ITEM_WIDTH          = model.ITEM_WIDTH;
                entity.ITEM_HEIGHT         = model.ITEM_HEIGHT;
                entity.ITEM_WEIGHT         = model.ITEM_WEIGHT;
                entity.BIG_ZONE            = model.BIG_ZONE;
            }
            else
            {
                Type type  = typeof(Apps.Models.SCV.SHIPMENT.SHIPMENT_ALLOC_REQUEST_MODEL);
                Type typeE = typeof(Apps.Models.SHIPMENT_ALLOC_REQUEST);
                foreach (var item in updateProperties)
                {
                    System.Reflection.PropertyInfo pi  = type.GetProperty(item);
                    System.Reflection.PropertyInfo piE = typeE.GetProperty(item);
                    piE.SetValue(entity, pi.GetValue(model), null);
                }
            }


            m_Rep.Modify(entity, updateProperties);
        }
 /// <summary>
 /// SetPropertyValue
 /// </summary>
 protected override void SetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, object value, System.Globalization.CultureInfo culture)
 {
     propertyInfo.SetValue(target, value, System.Reflection.BindingFlags.Default, null, null, culture);
 }
示例#11
0
 private bool TrySetProperty(System.Reflection.PropertyInfo property, object destObj, Components.Aphid.Interpreter.AphidObject srcObj)
 {
     if ((property.PropertyType == typeof(byte)))
     {
         property.SetValue(destObj, System.Convert.ToByte(srcObj.Value), null);
         return(true);
     }
     else
     {
         if ((property.PropertyType == typeof(sbyte)))
         {
             property.SetValue(destObj, System.Convert.ToSByte(srcObj.Value), null);
             return(true);
         }
         else
         {
             if ((property.PropertyType == typeof(short)))
             {
                 property.SetValue(destObj, System.Convert.ToInt16(srcObj.Value), null);
                 return(true);
             }
             else
             {
                 if ((property.PropertyType == typeof(ushort)))
                 {
                     property.SetValue(destObj, System.Convert.ToUInt16(srcObj.Value), null);
                     return(true);
                 }
                 else
                 {
                     if ((property.PropertyType == typeof(int)))
                     {
                         property.SetValue(destObj, System.Convert.ToInt32(srcObj.Value), null);
                         return(true);
                     }
                     else
                     {
                         if ((property.PropertyType == typeof(uint)))
                         {
                             property.SetValue(destObj, System.Convert.ToUInt32(srcObj.Value), null);
                             return(true);
                         }
                         else
                         {
                             if ((property.PropertyType == typeof(long)))
                             {
                                 property.SetValue(destObj, System.Convert.ToInt64(srcObj.Value), null);
                                 return(true);
                             }
                             else
                             {
                                 if ((property.PropertyType == typeof(ulong)))
                                 {
                                     property.SetValue(destObj, System.Convert.ToUInt64(srcObj.Value), null);
                                     return(true);
                                 }
                                 else
                                 {
                                     if ((property.PropertyType == typeof(byte[])))
                                     {
                                         property.SetValue(destObj, srcObj.GetList().Select(x => (System.Byte)x.GetNumber()).ToArray(), null);
                                         return(true);
                                     }
                                     else
                                     {
                                         if ((property.PropertyType == typeof(sbyte[])))
                                         {
                                             property.SetValue(destObj, srcObj.GetList().Select(x => (System.SByte)x.GetNumber()).ToArray(), null);
                                             return(true);
                                         }
                                         else
                                         {
                                             if ((property.PropertyType == typeof(short[])))
                                             {
                                                 property.SetValue(destObj, srcObj.GetList().Select(x => (System.Int16)x.GetNumber()).ToArray(), null);
                                                 return(true);
                                             }
                                             else
                                             {
                                                 if ((property.PropertyType == typeof(ushort[])))
                                                 {
                                                     property.SetValue(destObj, srcObj.GetList().Select(x => (System.UInt16)x.GetNumber()).ToArray(), null);
                                                     return(true);
                                                 }
                                                 else
                                                 {
                                                     if ((property.PropertyType == typeof(int[])))
                                                     {
                                                         property.SetValue(destObj, srcObj.GetList().Select(x => (System.Int32)x.GetNumber()).ToArray(), null);
                                                         return(true);
                                                     }
                                                     else
                                                     {
                                                         if ((property.PropertyType == typeof(uint[])))
                                                         {
                                                             property.SetValue(destObj, srcObj.GetList().Select(x => (System.UInt32)x.GetNumber()).ToArray(), null);
                                                             return(true);
                                                         }
                                                         else
                                                         {
                                                             if ((property.PropertyType == typeof(long[])))
                                                             {
                                                                 property.SetValue(destObj, srcObj.GetList().Select(x => (System.Int64)x.GetNumber()).ToArray(), null);
                                                                 return(true);
                                                             }
                                                             else
                                                             {
                                                                 if ((property.PropertyType == typeof(ulong[])))
                                                                 {
                                                                     property.SetValue(destObj, srcObj.GetList().Select(x => (System.UInt64)x.GetNumber()).ToArray(), null);
                                                                     return(true);
                                                                 }
                                                                 else
                                                                 {
                                                                     if ((property.PropertyType == typeof(decimal[])))
                                                                     {
                                                                         property.SetValue(destObj, srcObj.GetList().Select(x => x.GetNumber()).ToArray(), null);
                                                                         return(true);
                                                                     }
                                                                     else
                                                                     {
                                                                         if ((property.PropertyType == typeof(string[])))
                                                                         {
                                                                             property.SetValue(destObj, srcObj.GetList().Select(x => x.GetString()).ToArray(), null);
                                                                             return(true);
                                                                         }
                                                                         else
                                                                         {
                                                                             if ((property.PropertyType == typeof(bool[])))
                                                                             {
                                                                                 property.SetValue(destObj, srcObj.GetList().Select(x => x.GetBool()).ToArray(), null);
                                                                                 return(true);
                                                                             }
                                                                             else
                                                                             {
                                                                                 return(false);
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
示例#12
0
        /// <summary>
        /// Lets process our .Body content and build up our controls collection
        /// inside the 'BodyContent' placeholder.
        ///
        /// User controls are insterted into the blog in the following format..
        /// [UserControl:~/path/usercontrol.ascx]
        ///
        /// TODO : Expose user control parameters.
        ///
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            // Used to track where we are in the 'Body' as we parse it.
            int         currentPosition = 0;
            string      content         = Body;
            PlaceHolder bodyContent     = (PlaceHolder)FindControl("BodyContent");

            if (bodyContent != null)
            {
                MatchCollection myMatches = _BodyRegex.Matches(content);

                foreach (Match myMatch in myMatches)
                {
                    // Add literal for content before custom tag should it exist.
                    if (myMatch.Index > currentPosition)
                    {
                        bodyContent.Controls.Add(new LiteralControl(content.Substring(currentPosition, myMatch.Index - currentPosition)));
                    }

                    // Now lets add our user control.
                    try
                    {
                        string  all         = myMatch.Groups[1].Value.Trim();
                        Control usercontrol = null;

                        if (!all.EndsWith(".ascx", StringComparison.OrdinalIgnoreCase))
                        {
                            int index = all.IndexOf(".ascx", StringComparison.OrdinalIgnoreCase) + 5;
                            usercontrol = LoadControl(all.Substring(0, index));

                            string   parameters      = Server.HtmlDecode(all.Substring(index));
                            Type     type            = usercontrol.GetType();
                            string[] paramCollection = parameters.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);

                            foreach (string param in paramCollection)
                            {
                                string name  = param.Split('=')[0].Trim();
                                string value = param.Split('=')[1].Trim();
                                System.Reflection.PropertyInfo property = type.GetProperty(name);
                                property.SetValue(usercontrol, Convert.ChangeType(value, property.PropertyType, CultureInfo.InvariantCulture), null);
                            }
                        }
                        else
                        {
                            usercontrol = LoadControl(all);
                        }

                        bodyContent.Controls.Add(usercontrol);

                        // Now we will update our position.
                        //currentPosition = myMatch.Index + myMatch.Groups[0].Length;
                    }
                    catch (Exception)
                    {
                        // Whoopss, can't load that control so lets output something that tells the developer that theres a problem.
                        bodyContent.Controls.Add(new LiteralControl("ERROR - UNABLE TO LOAD CONTROL : " + myMatch.Groups[1].Value));
                    }

                    currentPosition = myMatch.Index + myMatch.Groups[0].Length;
                }

                // Finally we add any trailing static text.
                bodyContent.Controls.Add(new LiteralControl(content.Substring(currentPosition, content.Length - currentPosition)));
            }
            else
            {
                // We have no placeholder so we assume this is an old style <% =Body %> theme and do nothing.
            }
        }
        private void SetupMetadataHandlersForAccount(Mock <IOrganizationService> orgSvc)
        {
            EntityMetadata entityMetadata = new EntityMetadata();

            entityMetadata.LogicalName   = "account";
            entityMetadata.SchemaName    = "account";
            entityMetadata.EntitySetName = "accounts";
            entityMetadata.DisplayName   = new Label("Account", 1033);
            entityMetadata.DisplayName.UserLocalizedLabel           = new LocalizedLabel("Account", 1033);
            entityMetadata.DisplayCollectionName                    = new Label("Accounts", 1033);
            entityMetadata.DisplayCollectionName.UserLocalizedLabel = new LocalizedLabel("Accounts", 1033);

            var attribmetadata = new List <AttributeMetadata>()
            {
                new DateTimeAttributeMetadata(DateTimeFormat.DateOnly, "dateonlyfield"),
                new DateTimeAttributeMetadata(DateTimeFormat.DateAndTime, "datetimeNormal"),
                new DateTimeAttributeMetadata(DateTimeFormat.DateAndTime, "datetimeTZindependant")
                {
                    DateTimeBehavior = new DateTimeBehavior()
                    {
                        Value = "TimeZoneIndependent"
                    }
                }
            };

            //entityMetadata.ManyToOneRelationships
            var ManyToOneRels = new List <OneToManyRelationshipMetadata>()
            {
                new OneToManyRelationshipMetadata()
                {
                    ReferencingAttribute = "field02",
                    ReferencedEntity     = "account",
                    ReferencingEntityNavigationPropertyName = "field02_account"
                },
                new OneToManyRelationshipMetadata()
                {
                    ReferencingAttribute = "field02",
                    ReferencedEntity     = "contact",
                    ReferencingEntityNavigationPropertyName = "field02_contact"
                },
                new OneToManyRelationshipMetadata()
                {
                    ReferencingAttribute = "field07",
                    ReferencedEntity     = "account",
                    ReferencingEntityNavigationPropertyName = "field07account"
                }
            };

            System.Reflection.PropertyInfo proInfo = entityMetadata.GetType().GetProperty("ManyToOneRelationships");
            if (proInfo != null)
            {
                proInfo.SetValue(entityMetadata, ManyToOneRels.ToArray(), null);
            }
            ;

            System.Reflection.PropertyInfo proInfo1 = entityMetadata.GetType().GetProperty("ObjectTypeCode");
            if (proInfo1 != null)
            {
                proInfo1.SetValue(entityMetadata, 1, null);
            }

            System.Reflection.PropertyInfo proInfo3 = entityMetadata.GetType().GetProperty("Attributes");
            if (proInfo3 != null)
            {
                proInfo3.SetValue(entityMetadata, attribmetadata.ToArray(), null);
            }

            RetrieveEntityResponse retrieveEntityResponse = new RetrieveEntityResponse();

            retrieveEntityResponse.Results.Add("EntityMetadata", entityMetadata);

            List <EntityMetadata> entities = new List <EntityMetadata>();

            entities.Add(entityMetadata);

            RetrieveAllEntitiesResponse retrieveAllEntitiesResponse = new RetrieveAllEntitiesResponse();

            retrieveAllEntitiesResponse.Results.Add("EntityMetadata", entities.ToArray());

            orgSvc.Setup(f => f.Execute(It.IsAny <RetrieveEntityRequest>())).Returns(retrieveEntityResponse);
            orgSvc.Setup(f => f.Execute(It.IsAny <RetrieveAllEntitiesRequest>())).Returns(retrieveAllEntitiesResponse);
        }
示例#14
0
        public virtual void Modify(ref ValidationErrors errors, Apps.Models.SCV.TRANSFER.TRANSFER_ORDER_DETAIL_MODEL model, params string[] updateProperties)
        {
            Apps.Models.TRANSFER_ORDER_DETAIL entity = m_Rep.GetById(model.INTERNAL_TRANSFER_LINE_NUM);
            if (entity == null)
            {
                errors.Add(Resource.Disable);
                return;
            }
            if (updateProperties.Count() <= 0)
            {
                entity.INTERNAL_TRANSFER_LINE_NUM = model.INTERNAL_TRANSFER_LINE_NUM;
                entity.INTERNAL_TRANSFER_NUM      = model.INTERNAL_TRANSFER_NUM;
                entity.TRANSFER_ID             = model.TRANSFER_ID;
                entity.LINE_NUM                = model.LINE_NUM;
                entity.WAREHOUSE               = model.WAREHOUSE;
                entity.FROM_LOC                = model.FROM_LOC;
                entity.TO_LOC                  = model.TO_LOC;
                entity.COMPANY                 = model.COMPANY;
                entity.ITEM                    = model.ITEM;
                entity.ITEM_DESC               = model.ITEM_DESC;
                entity.FROM_LPN                = model.FROM_LPN;
                entity.TO_LPN                  = model.TO_LPN;
                entity.TOTAL_QTY               = model.TOTAL_QTY;
                entity.FROM_QTY                = model.FROM_QTY;
                entity.TO_QTY                  = model.TO_QTY;
                entity.QUANTITY_UM             = model.QUANTITY_UM;
                entity.BEGIN_DATE_TIME         = model.BEGIN_DATE_TIME;
                entity.END_DATE_TIME           = model.END_DATE_TIME;
                entity.ATTRIBUTE_NUM           = model.ATTRIBUTE_NUM;
                entity.INVENTORY_STS           = model.INVENTORY_STS;
                entity.LOCATING_RULE           = model.LOCATING_RULE;
                entity.CREATED_USER            = model.CREATED_USER;
                entity.CREATED_DATE_TIME       = model.CREATED_DATE_TIME;
                entity.LAST_MODIFIED_USER      = model.LAST_MODIFIED_USER;
                entity.LAST_MODIFIED_DATE_TIME = model.LAST_MODIFIED_DATE_TIME;
                entity.USER_DEF1               = model.USER_DEF1;
                entity.USER_DEF2               = model.USER_DEF2;
                entity.USER_DEF3               = model.USER_DEF3;
                entity.USER_DEF4               = model.USER_DEF4;
                entity.USER_DEF5               = model.USER_DEF5;
                entity.USER_DEF6               = model.USER_DEF6;
                entity.USER_DEF7               = model.USER_DEF7;
                entity.USER_DEF8               = model.USER_DEF8;
                entity.CART_ID                 = model.CART_ID;
                entity.CART_POS                = model.CART_POS;
                entity.STATUS                  = model.STATUS;
                entity.ATTRIBUTE1              = model.ATTRIBUTE1;
                entity.ATTRIBUTE2              = model.ATTRIBUTE2;
                entity.ATTRIBUTE3              = model.ATTRIBUTE3;
                entity.ATTRIBUTE4              = model.ATTRIBUTE4;
                entity.ATTRIBUTE5              = model.ATTRIBUTE5;
                entity.ATTRIBUTE6              = model.ATTRIBUTE6;
                entity.ATTRIBUTE7              = model.ATTRIBUTE7;
                entity.ATTRIBUTE8              = model.ATTRIBUTE8;
                entity.PARENT_LPN              = model.PARENT_LPN;
                entity.REFERENCE_ID            = model.REFERENCE_ID;
                entity.REFERENCE_NUM           = model.REFERENCE_NUM;
                entity.REFERENCE_NUM_TYPE      = model.REFERENCE_NUM_TYPE;
                entity.REFERENCE_LINE_NUM      = model.REFERENCE_LINE_NUM;
                entity.PROCESS_STAMP           = model.PROCESS_STAMP;
                entity.UPLOAD_INTERFACE_FLAG   = model.UPLOAD_INTERFACE_FLAG;
            }
            else
            {
                Type type  = typeof(Apps.Models.SCV.TRANSFER.TRANSFER_ORDER_DETAIL_MODEL);
                Type typeE = typeof(Apps.Models.TRANSFER_ORDER_DETAIL);
                foreach (var item in updateProperties)
                {
                    System.Reflection.PropertyInfo pi  = type.GetProperty(item);
                    System.Reflection.PropertyInfo piE = typeE.GetProperty(item);
                    piE.SetValue(entity, pi.GetValue(model), null);
                }
            }


            m_Rep.Modify(entity, updateProperties);
        }
示例#15
0
 // 實作 IValueProvider 介面的寫入動作
 public void SetValue(object oTarget, object oValue)
 {
     _oMemberInfo.SetValue(oTarget, oValue);
 }
示例#16
0
        private void AddAnnotation(PointF p)
        {
            _start = p;
            try
            {
                _annotationToAdd            = (AnnotationBase)Activator.CreateInstance(NewAnnotationType);
                _annotationToAdd.Attachment = Attachment;
                _annotationToAdd.Location   = Helpers.CoordsToAnnoPoint(Chart, _annotationToAdd, _start);

                if (_annotationToAdd is Text)
                {
                    ((Text)_annotationToAdd).Content = "New Text Annotation";
                    if (ShowContentEditor(_annotationToAdd, p))
                    {
                        ContentEditor.Accept = () =>
                        {
                            this.Annotations.Add(_annotationToAdd);
                            SelectedAnnotation = _annotationToAdd;
                            HideContentEditor();
                        };
                        ContentEditor.Reject = () =>
                        {
                            _annotationToAdd = null;
                            HideContentEditor();
                        };
                    }
                }
                else if (_annotationToAdd is Polygon)
                {
                    var polygon = PolygonAddFunc(_start);
                    polygon.Attachment = Attachment;
                    for (int i = 0; i < polygon.Points.Count; i++)
                    {
                        polygon.Points[i] = Helpers.CoordsToAnnoPoint(Chart, polygon, polygon.Points[i]);
                    }
                    _annotationToAdd = polygon;
                }
                else
                {
                    System.Reflection.PropertyInfo pi = _annotationToAdd.GetType().GetProperty("Content");
                    if (pi != null)
                    {
                        pi.SetValue(_annotationToAdd, pi.ReflectedType.Name, null);
                    }
                }

                if (DefaultStyle != null)
                {
                    _annotationToAdd.Style.ApplyStyle(DefaultStyle);
                }

                if (DefaultContentStyle != null)
                {
                    _annotationToAdd.ContentStyle.ApplyStyle(DefaultContentStyle);

                    // special case of Text annotations.  Text is added for these annotations using
                    // the Style instead of ContentStyle
                    if (_annotationToAdd is Text)
                    {
                        _annotationToAdd.Style.ApplyStyle(DefaultContentStyle);
                    }
                }

                this.Annotations.Add(_annotationToAdd);
                SelectedAnnotation = _annotationToAdd;

                if (_flexChart is C1.Win.Chart.Finance.FinancialChart)
                {
                    C1.Chart.Finance.FinancialChartType finType = ((C1.Win.Chart.Finance.FinancialChart)_flexChart).ChartType;
                    if (finType.ToString().Contains("CandleVolume"))
                    {
                        _annotationToAdd.Attachment = AnnotationAttachment.Absolute;
                    }
                }

                _drawing = true;   //Start drawing on MouseMove
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        private static void _SetModelValue(object model, System.Reflection.PropertyInfo pi, object value)
        {
            if (value == DBNull.Value)
            {
                return;
            }
            //switch (pi.PropertyType.ToString().ToLower())
            //{
            //    case "system.string":
            //        pi.SetValue(model, value.ToString(), null);
            //        break;
            //    case "system.int32":
            //        pi.SetValue(model, Convert.ToInt32(value), null);
            //        break;
            //    case "system.decimal":
            //        pi.SetValue(model, Convert.ToDecimal(value), null);
            //        break;
            //    case "system.datetime":
            //        pi.SetValue(model, Convert.ToDateTime(value), null);
            //        break;
            //    case "system.float":
            //        pi.SetValue(model, Convert.ToDecimal(value), null);
            //        break;
            //    case "system.boolean":
            //        pi.SetValue(model, Convert.ToBoolean(value), null);
            //        break;

            //}

            if (pi.PropertyType.IsGenericType && pi.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                if (pi.PropertyType.GetGenericArguments()[0].Name.ToLower() == "int32")
                {
                    if (value == DBNull.Value)
                    {
                        pi.SetValue(model, null, null);
                    }
                    else
                    {
                        pi.SetValue(model, Convert.ToInt32(value), null);
                    }
                }

                if (pi.PropertyType.GetGenericArguments()[0].Name.ToLower() == "string")
                {
                    if (value == DBNull.Value)
                    {
                        pi.SetValue(model, null, null);
                    }
                    else
                    {
                        pi.SetValue(model, Convert.ToString(value), null);
                    }
                }

                if (pi.PropertyType.GetGenericArguments()[0].Name.ToLower() == "decimal")
                {
                    if (value == DBNull.Value)
                    {
                        pi.SetValue(model, null, null);
                    }
                    else
                    {
                        decimal o;
                        if (decimal.TryParse(string.Format("{0}", value), out o))
                        {
                            pi.SetValue(model, o, null);
                        }
                        else
                        {
                            pi.SetValue(model, Converts.ToTryDecimal(value, 0), null);
                        }
                    }
                }

                if (pi.PropertyType.GetGenericArguments()[0].Name.ToLower() == "datetime")
                {
                    if (value == DBNull.Value)
                    {
                        pi.SetValue(model, null, null);
                    }
                    else
                    {
                        pi.SetValue(model, Convert.ToDateTime(value), null);
                    }
                }

                if (pi.PropertyType.GetGenericArguments()[0].Name.ToLower() == "float")
                {
                    if (value == DBNull.Value)
                    {
                        pi.SetValue(model, null, null);
                    }
                    else
                    {
                        pi.SetValue(model, Convert.ToDecimal(value), null);
                    }
                }

                if (pi.PropertyType.GetGenericArguments()[0].Name.ToLower() == "boolean")
                {
                    if (value == DBNull.Value)
                    {
                        pi.SetValue(model, null, null);
                    }
                    else
                    {
                        pi.SetValue(model, Convert.ToBoolean(value), null);
                    }
                }
                if (pi.PropertyType.GetGenericArguments()[0].Name.ToLower() == "int64")
                {
                    if (value == DBNull.Value)
                    {
                        pi.SetValue(model, null, null);
                    }
                    else
                    {
                        pi.SetValue(model, Convert.ToInt64(value), null);
                    }
                }
            }
            else
            {
                if (pi.PropertyType.Name.ToLower() == "int32")
                {
                    pi.SetValue(model, Convert.ToInt32(value), null);
                }
                if (pi.PropertyType.Name.ToLower() == "string")
                {
                    pi.SetValue(model, Convert.ToString(value), null);
                }
                if (pi.PropertyType.Name.ToLower() == "decimal")
                {
                    pi.SetValue(model, Convert.ToDecimal(value), null);
                }
                if (pi.PropertyType.Name.ToLower() == "datetime")
                {
                    pi.SetValue(model, Convert.ToDateTime(value), null);
                }
                if (pi.PropertyType.Name.ToLower() == "float")
                {
                    pi.SetValue(model, Convert.ToDecimal(value), null);
                }

                if (pi.PropertyType.Name.ToLower() == "boolean")
                {
                    pi.SetValue(model, Convert.ToBoolean(value), null);
                }
                if (pi.PropertyType.Name.ToLower() == "int64")
                {
                    if (value == DBNull.Value)
                    {
                        pi.SetValue(model, 0, null);
                    }
                    else
                    {
                        pi.SetValue(model, Convert.ToInt64(value), null);
                    }
                    //pi.SetValue(model, Convert.ToInt64(value), null);
                }
                if (pi.PropertyType.Name.ToLower() == "byte[]")
                {
                    if (value == DBNull.Value)
                    {
                        pi.SetValue(model, 0, null);
                    }
                    else
                    {
                        pi.SetValue(model, (byte[])value, null);
                    }
                }
            }
        }
示例#18
0
文件: XMLServer.cs 项目: radtek/WCF
        private static void BuildEntity(dynamic entity, string[] xmls, System.Reflection.PropertyInfo property, ref int index)
        {
            var     groupType  = property.PropertyType.GetGenericArguments()[0];
            var     listType   = typeof(List <>).MakeGenericType(groupType);
            dynamic list       = listType.GetConstructor(new Type[0]).Invoke(new object[0]);
            string  groupsName = string.Empty;

            for (int i = index; i < xmls.Length; i++)
            {
                if (string.IsNullOrEmpty(groupsName))
                {
                    groupsName = xmls[i];
                }
                else
                {
                    if (groupsName == xmls[i])
                    {
                        index = i;
                        break;
                    }
                }
                if (xmls[i].ToUpper() == groupType.Name.ToUpper())
                {
                    Type gtype          = property.PropertyType.GetGenericArguments()[0];
                    var  newgroup       = gtype.GetConstructor(new Type[0]).Invoke(new object[0]);
                    int  twinsNameIndex = 0;
                    while (xmls[++i].ToUpper() != groupType.Name.ToUpper())
                    {
                        foreach (var gproperty in newgroup.GetType().GetProperties())
                        {
                            if (xmls[i].ToUpper() == gproperty.Name.ToUpper())
                            {
                                if (twinsNameIndex % 2 == 0)
                                {
                                    if (gproperty.PropertyType.IsGenericType && gproperty.PropertyType.GetGenericTypeDefinition().Equals(typeof(IList <>)))
                                    {
                                        if (xmls[i + 1].ToUpper() != gproperty.Name.ToUpper())
                                        {
                                            //进入递归
                                            BuildEntity(newgroup, xmls, gproperty, ref i);
                                        }
                                    }
                                    else if (gproperty.PropertyType.IsGenericType && gproperty.PropertyType.GetGenericTypeDefinition().Equals(typeof(Nullable <>)))
                                    {
                                        NullableConverter nullableConverter = new NullableConverter(gproperty.PropertyType);
                                        gproperty.SetValue(newgroup, Convert.ChangeType(xmls[i + 1], nullableConverter.UnderlyingType), null);
                                    }
                                    else if (gproperty.PropertyType.BaseType == typeof(BaseGroup))
                                    {
                                        BuildGroup(xmls, i, newgroup, gproperty);
                                    }
                                    else
                                    {
                                        if (xmls[i + 1].ToUpper() != gproperty.Name.ToUpper())
                                        {
                                            gproperty.SetValue(newgroup, Convert.ChangeType(xmls[i + 1], gproperty.PropertyType), null);
                                        }
                                    }
                                }
                                twinsNameIndex++;
                                break;
                            }
                        }
                    }
                    list.GetType().GetMethod("Add").Invoke(list, new object[] { newgroup });
                }
            }
            property.SetValue(entity, list, null);
        }
示例#19
0
        /// <summary>
        /// 从Excel2003取数据并记录到List集合里
        /// </summary>
        /// <param name="cellHeard">单元头的Key和Value:{ { "UserName", "姓名" }, { "Age", "年龄" } };</param>
        /// <param name="filePath">保存文件绝对路径</param>
        /// <param name="errorMsg">错误信息</param>
        /// <returns>转换好的List对象集合</returns>
        private static List <T> Excel2003ToEntityList <T>(Dictionary <string, string> cellHeard, string filePath, out StringBuilder errorMsg) where T : new()
        {
            errorMsg = new StringBuilder();                 // 错误信息,Excel转换到实体对象时,会有格式的错误信息
            List <T>      enlist = new List <T>();          // 转换后的集合
            List <string> keys   = cellHeard.Keys.ToList(); // 要赋值的实体对象属性名称

            try
            {
                using (FileStream fs = File.OpenRead(filePath))
                {
                    HSSFWorkbook workbook = new HSSFWorkbook(fs);
                    HSSFSheet    sheet    = (HSSFSheet)workbook.GetSheetAt(0); // 获取此文件第一个Sheet页
                    for (int i = 1; i <= sheet.LastRowNum; i++)                // 从1开始,第0行为单元头
                    {
                        // 1.判断当前行是否空行,若空行就不在进行读取下一行操作,结束Excel读取操作
                        if (sheet.GetRow(i) == null)
                        {
                            break;
                        }

                        T      en     = new T();
                        string errStr = ""; // 当前行转换时,是否有错误信息,格式为:第1行数据转换异常:XXX列;
                        for (int j = 0; j < keys.Count; j++)
                        {
                            // 2.若属性头的名称包含'.',就表示是子类里的属性,那么就要遍历子类,eg:UserEn.TrueName
                            if (keys[j].IndexOf(".") >= 0)
                            {
                                // 2.1解析子类属性
                                string[] properotyArray        = keys[j].Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
                                string   subClassName          = properotyArray[0];                                   // '.'前面的为子类的名称
                                string   subClassProperotyName = properotyArray[1];                                   // '.'后面的为子类的属性名称
                                System.Reflection.PropertyInfo subClassInfo = en.GetType().GetProperty(subClassName); // 获取子类的类型
                                if (subClassInfo != null)
                                {
                                    // 2.1.1 获取子类的实例
                                    var subClassEn = en.GetType().GetProperty(subClassName).GetValue(en, null);
                                    // 2.1.2 根据属性名称获取子类里的属性信息
                                    System.Reflection.PropertyInfo properotyInfo = subClassInfo.PropertyType.GetProperty(subClassProperotyName);
                                    if (properotyInfo != null)
                                    {
                                        try
                                        {
                                            // Excel单元格的值转换为对象属性的值,若类型不对,记录出错信息
                                            properotyInfo.SetValue(subClassEn, GetExcelCellToProperty(properotyInfo.PropertyType, sheet.GetRow(i).GetCell(j)), null);
                                        }
                                        catch (Exception e)
                                        {
                                            if (errStr.Length == 0)
                                            {
                                                errStr = "第" + i + "行数据转换异常:";
                                            }
                                            errStr += cellHeard[keys[j]] + "列;";
                                        }
                                    }
                                }
                            }
                            else
                            {
                                // 3.给指定的属性赋值
                                System.Reflection.PropertyInfo properotyInfo = en.GetType().GetProperty(keys[j]);
                                if (properotyInfo != null)
                                {
                                    try
                                    {
                                        // Excel单元格的值转换为对象属性的值,若类型不对,记录出错信息
                                        properotyInfo.SetValue(en, GetExcelCellToProperty(properotyInfo.PropertyType, sheet.GetRow(i).GetCell(j)), null);
                                    }
                                    catch (Exception e)
                                    {
                                        if (errStr.Length == 0)
                                        {
                                            errStr = "第" + i + "行数据转换异常:";
                                        }
                                        errStr += cellHeard[keys[j]] + "列;";
                                    }
                                }
                            }
                        }
                        // 若有错误信息,就添加到错误信息里
                        if (errStr.Length > 0)
                        {
                            errorMsg.AppendLine(errStr);
                        }
                        enlist.Add(en);
                    }
                }
                return(enlist);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public virtual void Modify(ref ValidationErrors errors, Apps.Models.SCV.AR.AR_RECEIPT_LOCATE_REQUEST_MODEL model, params string[] updateProperties)
        {
            Apps.Models.AR_RECEIPT_LOCATE_REQUEST entity = m_Rep.GetById(model.INTERNAL_REC_LOC_NUM);
            if (entity == null)
            {
                errors.Add(Resource.Disable);
                return;
            }
            if (updateProperties.Count() <= 0)
            {
                entity.INTERNAL_REC_LOC_NUM = model.INTERNAL_REC_LOC_NUM;
                entity.WAREHOUSE            = model.WAREHOUSE;
                entity.COMPANY = model.COMPANY;
                entity.INTERNAL_CONTAINER_NUM = model.INTERNAL_CONTAINER_NUM;
                entity.CONTAINER_ID           = model.CONTAINER_ID;
                entity.ITEM                      = model.ITEM;
                entity.ITEM_DESC                 = model.ITEM_DESC;
                entity.LOCATE_QTY                = model.LOCATE_QTY;
                entity.QUANTITY_UM               = model.QUANTITY_UM;
                entity.ATTRIBUTE_NUM             = model.ATTRIBUTE_NUM;
                entity.INVENTORY_STS             = model.INVENTORY_STS;
                entity.FROM_LOC                  = model.FROM_LOC;
                entity.TO_LOC                    = model.TO_LOC;
                entity.FROM_TEMPLATE_FIELD1      = model.FROM_TEMPLATE_FIELD1;
                entity.FROM_TEMPLATE_FIELD2      = model.FROM_TEMPLATE_FIELD2;
                entity.FROM_TEMPLATE_FIELD3      = model.FROM_TEMPLATE_FIELD3;
                entity.FROM_TEMPLATE_FIELD4      = model.FROM_TEMPLATE_FIELD4;
                entity.FROM_TEMPLATE_FIELD5      = model.FROM_TEMPLATE_FIELD5;
                entity.TO_TEMPLATE_FIELD1        = model.TO_TEMPLATE_FIELD1;
                entity.TO_TEMPLATE_FIELD2        = model.TO_TEMPLATE_FIELD2;
                entity.TO_TEMPLATE_FIELD3        = model.TO_TEMPLATE_FIELD3;
                entity.TO_TEMPLATE_FIELD4        = model.TO_TEMPLATE_FIELD4;
                entity.TO_TEMPLATE_FIELD5        = model.TO_TEMPLATE_FIELD5;
                entity.ZONE                      = model.ZONE;
                entity.CONVERTED_QTY             = model.CONVERTED_QTY;
                entity.CONVERTED_QTY_UM          = model.CONVERTED_QTY_UM;
                entity.TASK_CREATED              = model.TASK_CREATED;
                entity.RECEIPT_ID                = model.RECEIPT_ID;
                entity.RECEIPT_TYPE              = model.RECEIPT_TYPE;
                entity.RECEIPT_DATE              = model.RECEIPT_DATE;
                entity.PARENT_CONTAINER_NUM      = model.PARENT_CONTAINER_NUM;
                entity.PARENT_CONTAINER_ID       = model.PARENT_CONTAINER_ID;
                entity.INTERNAL_RECEIPT_NUM      = model.INTERNAL_RECEIPT_NUM;
                entity.INTERNAL_RECEIPT_LINE_NUM = model.INTERNAL_RECEIPT_LINE_NUM;
                entity.USER_STAMP                = model.USER_STAMP;
                entity.DATE_TIME_STAMP           = model.DATE_TIME_STAMP;
                entity.INTERNAL_WAVE_NUM         = model.INTERNAL_WAVE_NUM;
            }
            else
            {
                Type type  = typeof(Apps.Models.SCV.AR.AR_RECEIPT_LOCATE_REQUEST_MODEL);
                Type typeE = typeof(Apps.Models.AR_RECEIPT_LOCATE_REQUEST);
                foreach (var item in updateProperties)
                {
                    System.Reflection.PropertyInfo pi  = type.GetProperty(item);
                    System.Reflection.PropertyInfo piE = typeE.GetProperty(item);
                    piE.SetValue(entity, pi.GetValue(model), null);
                }
            }


            m_Rep.Modify(entity, updateProperties);
        }
示例#21
0
        private void btnProcess_Click(object sender, EventArgs e)
        {
            //process everything
            System.Reflection.PropertyInfo pi = (cmbStepTwoField.SelectedItem as PropInfo).PropertyInfo;
            object newValue;

            switch ((cmbStepTwoField.SelectedItem as PropInfo).PropertyInfo.Name)
            {
            case "Type":
            case "SubType":
            case "Special":
            case "Size":
                newValue = cmbStepTwoValue.SelectedIndex;
                break;

            case "Name":
                newValue = txtStepTwoValue.Text;
                break;

            default:
                int dummy;
                newValue = txtStepTwoValue.Text.ToString();
                if (!int.TryParse(newValue.ToString(), out dummy))
                {
                    MessageBox.Show("Only integer values are supported for the value field in step two.");
                    return;
                }
                newValue = dummy;
                break;
            }

            if (!chkFilterOn.Checked)
            { //process the change for EVERY item record. save changes immediately.
                if (MessageBox.Show(
                        "This change will be processed for every item immediately. The change is irreversible. Are you sure you want to continue? You may specify a filter by checking the filter option.", "No filter selected",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Exclamation) == DialogResult.No
                    )
                {
                    return;
                }

                rtfOutput.Text += "Processing change: set " + pi.Name + "(" + pi.PropertyType.ToString() + ")=" + newValue.ToString() + " for all items...";
                foreach (var rec in eif.Data)
                {
                    System.Reflection.PropertyInfo prop = rec.GetType().GetProperty(pi.Name);
                    prop.SetValue(rec, Convert.ChangeType(newValue, pi.PropertyType));
                }

                rtfOutput.Text += "done.\n\n";
            }
            else
            {
                object          compareValue;
                CompareOperator op;
                try
                {
                    op = (CompareOperator)cmbCompareType.SelectedIndex;
                    if (op == CompareOperator.REGEX && cmbCompareValue.Enabled)
                    {
                        MessageBox.Show("You can't use a regex to parse enumerated types");
                        return;
                    }
                }
                catch
                {
                    MessageBox.Show("Invalid comparison operator specified.");
                    return;
                }

                Regex comparer = null;
                if (op == CompareOperator.REGEX)
                {
                    try
                    {
                        compareValue = txtCompareValue.Text;
                        comparer     = new Regex(compareValue.ToString());
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Unable to parse regular expression:\n " + ex.Message, "Error!");
                        return;
                    }
                }
                else
                {
                    switch ((cmbStepThreeField.SelectedItem as PropInfo).PropertyInfo.Name)
                    {
                    case "Type":
                        compareValue = (ItemType)cmbCompareValue.SelectedIndex;
                        break;

                    case "SubType":
                        compareValue = (ItemSubType)cmbCompareValue.SelectedIndex;
                        break;

                    case "Special":
                        compareValue = (ItemSpecial)cmbCompareValue.SelectedIndex;
                        break;

                    case "Size":
                        compareValue = (ItemSize)cmbCompareValue.SelectedIndex;
                        break;

                    case "Name":
                        compareValue = txtCompareValue.Text;
                        break;

                    default:
                        compareValue = txtCompareValue.Text;
                        int dummy;
                        if (!int.TryParse(compareValue.ToString(), out dummy))
                        {
                            MessageBox.Show("Only integer values are allowed for this comparison type.", "Error parsing");
                            return;
                        }
                        compareValue = dummy;
                        break;
                    }
                }

                List <EIFRecord> filtered = eif.Data.Where(record =>
                {
                    EIFRecord rec = (EIFRecord)record;
                    if (rec == null || rec.ID == 0)
                    {
                        return(false);
                    }

                    System.Reflection.PropertyInfo comparePropertyInfo = (cmbStepThreeField.SelectedItem as PropInfo).PropertyInfo;
                    System.Reflection.PropertyInfo currentInfo         = rec.GetType().GetProperty(comparePropertyInfo.Name);
                    switch (op)
                    {
                    case CompareOperator.EQ:
                        return(compareValue.ToString() == currentInfo.GetValue(rec).ToString());

                    case CompareOperator.GT:
                        return(compareValue.ToString().CompareTo(currentInfo.GetValue(rec).ToString()) > 0);

                    case CompareOperator.GTE:
                        return(compareValue.ToString().CompareTo(currentInfo.GetValue(rec).ToString()) >= 0);

                    case CompareOperator.LT:
                        return(compareValue.ToString().CompareTo(currentInfo.GetValue(rec).ToString()) < 0);

                    case CompareOperator.LTE:
                        return(compareValue.ToString().CompareTo(currentInfo.GetValue(rec).ToString()) <= 0);

                    case CompareOperator.NE:
                        return(compareValue.ToString() != currentInfo.GetValue(rec).ToString());

                    case CompareOperator.REGEX:
                        object curValAsString = currentInfo.GetValue(rec);
                        if (curValAsString == null)
                        {
                            return(false);
                        }

                        return(comparer.IsMatch(curValAsString.ToString()));

                    default:
                        return(false);
                    }
                }).ToList();

                filtered.ForEach(rec =>
                {
                    if (!changes)
                    {
                        changes = true;
                    }

                    int index = rec.ID - 1;

                    rtfOutput.Text          += "Found matching item " + rec.Name + " (" + rec.ID + ")\n";
                    rtfOutput.Text          += "  replacing " + pi.Name + " (currently " + pi.GetValue(rec).ToString() + ") with new value " + newValue.ToString() + "\n";
                    rtfOutput.SelectionStart = rtfOutput.TextLength;
                    rtfOutput.ScrollToCaret();

                    object setter;
                    //enums are special: convert them to object
                    if (pi.PropertyType == typeof(ItemType) ||
                        pi.PropertyType == typeof(ItemSubType) ||
                        pi.PropertyType == typeof(ItemSpecial) ||
                        pi.PropertyType == typeof(ItemSize))
                    {
                        setter = Convert.ChangeType(Enum.ToObject(pi.PropertyType, newValue), pi.PropertyType);
                    }
                    else
                    {
                        setter = Convert.ChangeType(newValue, pi.PropertyType);
                    }

                    pi.SetValue(rec, setter);

                    //eif.ReplaceRecordAt(index, rec); //todo: way to modify pub files
                });
            }
        }
示例#22
0
        public virtual void Modify(ref ValidationErrors errors, Apps.Models.SCV.MISC.MISC_INVENTORY_HANDLING_MODEL model, params string[] updateProperties)
        {
            Apps.Models.MISC_INVENTORY_HANDLING entity = m_Rep.GetById(model.INTERNAL_NUM);
            if (entity == null)
            {
                errors.Add(Resource.Disable);
                return;
            }
            if (updateProperties.Count() <= 0)
            {
                entity.INTERNAL_NUM       = model.INTERNAL_NUM;
                entity.BATCH_ID           = model.BATCH_ID;
                entity.ERROR_TYPE         = model.ERROR_TYPE;
                entity.CART_ID            = model.CART_ID;
                entity.CART_POS           = model.CART_POS;
                entity.STATUS             = model.STATUS;
                entity.WAREHOUSE          = model.WAREHOUSE;
                entity.COMPANY            = model.COMPANY;
                entity.ITEM               = model.ITEM;
                entity.ITEM_DESC          = model.ITEM_DESC;
                entity.ATTRIBUTE_NUM      = model.ATTRIBUTE_NUM;
                entity.ATTRIBUTE1         = model.ATTRIBUTE1;
                entity.ATTRIBUTE2         = model.ATTRIBUTE2;
                entity.ATTRIBUTE3         = model.ATTRIBUTE3;
                entity.ATTRIBUTE4         = model.ATTRIBUTE4;
                entity.ATTRIBUTE5         = model.ATTRIBUTE5;
                entity.ATTRIBUTE6         = model.ATTRIBUTE6;
                entity.ATTRIBUTE7         = model.ATTRIBUTE7;
                entity.ATTRIBUTE8         = model.ATTRIBUTE8;
                entity.QUANTITY           = model.QUANTITY;
                entity.FROM_LOC           = model.FROM_LOC;
                entity.TO_LOC             = model.TO_LOC;
                entity.REFERENCE_TYPE     = model.REFERENCE_TYPE;
                entity.REFERNCE_ID        = model.REFERNCE_ID;
                entity.REFERENCE_NUM      = model.REFERENCE_NUM;
                entity.REFERENCE_LINE_NUM = model.REFERENCE_LINE_NUM;
                entity.REFERENCE_CONT_ID  = model.REFERENCE_CONT_ID;
                entity.REFERENCE_CONT_NUM = model.REFERENCE_CONT_NUM;
                entity.CHECKIN_USER       = model.CHECKIN_USER;
                entity.PUTAWAY_USER       = model.PUTAWAY_USER;
                entity.PICK_USER          = model.PICK_USER;
                entity.REBIN_USER         = model.REBIN_USER;
                entity.QC_USER            = model.QC_USER;
                entity.CREATE_USER        = model.CREATE_USER;
                entity.CREATE_DATE_TIME   = model.CREATE_DATE_TIME;
                entity.USER_STAMP         = model.USER_STAMP;
                entity.DATE_TIME_STAMP    = model.DATE_TIME_STAMP;
                entity.USER_DEF1          = model.USER_DEF1;
                entity.USER_DEF2          = model.USER_DEF2;
                entity.USER_DEF3          = model.USER_DEF3;
                entity.USER_DEF4          = model.USER_DEF4;
                entity.USER_DEF5          = model.USER_DEF5;
                entity.USER_DEF6          = model.USER_DEF6;
                entity.USER_DEF7          = model.USER_DEF7;
                entity.USER_DEF8          = model.USER_DEF8;
            }
            else
            {
                Type type  = typeof(Apps.Models.SCV.MISC.MISC_INVENTORY_HANDLING_MODEL);
                Type typeE = typeof(Apps.Models.MISC_INVENTORY_HANDLING);
                foreach (var item in updateProperties)
                {
                    System.Reflection.PropertyInfo pi  = type.GetProperty(item);
                    System.Reflection.PropertyInfo piE = typeE.GetProperty(item);
                    piE.SetValue(entity, pi.GetValue(model), null);
                }
            }


            m_Rep.Modify(entity, updateProperties);
        }
示例#23
0
 private void SetCommandText(string commandText, bool isProc)
 {
     if (OracleDal.clientType > 0)
     {
         Type t = _com.GetType();
         System.Reflection.PropertyInfo pi = t.GetProperty("BindByName");
         if (pi != null)
         {
             pi.SetValue(_com, true, null);
         }
     }
     _com.CommandText = isProc ? commandText : SqlFormat.Compatible(commandText, DataBaseType, false);
     if (!isProc && DataBaseType == DataBaseType.SQLite && _com.CommandText.Contains("charindex"))
     {
         _com.CommandText += " COLLATE NOCASE";//忽略大小写
     }
     //else if (isProc && dalType == DalType.MySql)
     //{
     //    _com.CommandText = "Call " + _com.CommandText;
     //}
     _com.CommandType = isProc ? CommandType.StoredProcedure : CommandType.Text;
     //if (isProc)
     //{
     //    if (commandText.Contains("SelectBase") && !_com.Parameters.Contains("ReturnValue"))
     //    {
     //        AddReturnPara();
     //        //检测是否存在分页存储过程,若不存在,则创建。
     //        Tool.DBTool.CreateSelectBaseProc(DataBaseType, ConnName);//内部分检测是否已创建过。
     //    }
     //}
     //else
     //{
     //上面if代码被注释了,下面代码忘了加!isProc判断,现补上。 取消多余的参数,新加的小贴心,过滤掉用户不小心写多的参数。
     if (!isProc && _com != null && _com.Parameters != null && _com.Parameters.Count > 0)
     {
         bool   needToReplace = (DataBaseType == DataBaseType.Oracle || DataBaseType == DataBaseType.MySql) && _com.CommandText.Contains("@");
         string paraName;
         for (int i = 0; i < _com.Parameters.Count; i++)
         {
             paraName = _com.Parameters[i].ParameterName.TrimStart(Pre);//默认自带前缀的,取消再判断
             if (needToReplace && _com.CommandText.IndexOf("@" + paraName) > -1)
             {
                 //兼容多数据库的参数(虽然提供了=:?"为兼容语法,但还是贴心的再处理一下)
                 switch (DataBaseType)
                 {
                 case DataBaseType.Oracle:
                 case DataBaseType.MySql:
                     _com.CommandText = _com.CommandText.Replace("@" + paraName, Pre + paraName);
                     break;
                 }
             }
             if (_com.CommandText.IndexOf(Pre + paraName, StringComparison.OrdinalIgnoreCase) == -1)
             {
                 _com.Parameters.RemoveAt(i);
                 i--;
             }
         }
     }
     // }
     //else
     //{
     //    string checkText = commandText.ToLower();
     //    //int index=
     //    //if (checkText.IndexOf("table") > -1 && (checkText.IndexOf("delete") > -1 || checkText.IndexOf("drop") > -1 || checkText.IndexOf("truncate") > -1))
     //    //{
     //    //    Log.WriteLog(commandText);
     //    //}
     //}
     if (IsRecordDebugInfo)
     {
         tempSql = GetParaInfo(_com.CommandText) + AppConst.BR + "execute time is: ";
     }
 }
 protected virtual void SetDateTimeValue(System.Reflection.PropertyInfo propertyInfo, object owner)
 {
     propertyInfo.SetValue(owner, DateTime.Now, null);
 }
        public virtual void Modify(ref ValidationErrors errors, Apps.Models.SCV.UPLOAD.UPLOAD_RECEIPT_CONTAINER_MODEL model, params string[] updateProperties)
        {
            Apps.Models.UPLOAD_RECEIPT_CONTAINER entity = m_Rep.GetById(model.INTERFACE_RECORD_ID);
            if (entity == null)
            {
                errors.Add(Resource.Disable);
                return;
            }
            if (updateProperties.Count() <= 0)
            {
                entity.INTERFACE_RECORD_ID       = model.INTERFACE_RECORD_ID;
                entity.INTERFACE_LINK_ID         = model.INTERFACE_LINK_ID;
                entity.INTERFACE_ACTION_CODE     = model.INTERFACE_ACTION_CODE;
                entity.INTERFACE_CONDITION       = model.INTERFACE_CONDITION;
                entity.PROCESS_STAMP             = model.PROCESS_STAMP;
                entity.INTERNAL_RECEIPT_NUM      = model.INTERNAL_RECEIPT_NUM;
                entity.INTERNAL_RECEIPT_LINE_NUM = model.INTERNAL_RECEIPT_LINE_NUM;
                entity.RECEIPT_ID         = model.RECEIPT_ID;
                entity.RECEIPT_TYPE       = model.RECEIPT_TYPE;
                entity.ERP_ORDER_LINE_NUM = model.ERP_ORDER_LINE_NUM;
                entity.CONTAINER_ID       = model.CONTAINER_ID;
                entity.CONTAINER_TYPE     = model.CONTAINER_TYPE;
                entity.PARENT             = model.PARENT;
                entity.COMPANY            = model.COMPANY;
                entity.ITEM            = model.ITEM;
                entity.ITEM_DESC       = model.ITEM_DESC;
                entity.ITEM_CLASS      = model.ITEM_CLASS;
                entity.QUANTITY        = model.QUANTITY;
                entity.QUANTITY_UM     = model.QUANTITY_UM;
                entity.STATUS          = model.STATUS;
                entity.WAREHOUSE       = model.WAREHOUSE;
                entity.LOCATING_RULE   = model.LOCATING_RULE;
                entity.FROM_LOCATION   = model.FROM_LOCATION;
                entity.TO_LOCATION     = model.TO_LOCATION;
                entity.DATE_TIME_STAMP = model.DATE_TIME_STAMP;
                entity.ATTRIBUTE_NUM   = model.ATTRIBUTE_NUM;
                entity.ATTRIBUTE1      = model.ATTRIBUTE1;
                entity.ATTRIBUTE2      = model.ATTRIBUTE2;
                entity.ATTRIBUTE3      = model.ATTRIBUTE3;
                entity.ATTRIBUTE4      = model.ATTRIBUTE4;
                entity.ATTRIBUTE5      = model.ATTRIBUTE5;
                entity.ATTRIBUTE6      = model.ATTRIBUTE6;
                entity.ATTRIBUTE7      = model.ATTRIBUTE7;
                entity.ATTRIBUTE8      = model.ATTRIBUTE8;
                entity.INVENTORY_STS   = model.INVENTORY_STS;
                entity.USER_STAMP      = model.USER_STAMP;
                entity.TASK_CREATED    = model.TASK_CREATED;
                entity.USER_DEF1       = model.USER_DEF1;
                entity.USER_DEF2       = model.USER_DEF2;
                entity.USER_DEF3       = model.USER_DEF3;
                entity.USER_DEF4       = model.USER_DEF4;
                entity.USER_DEF5       = model.USER_DEF5;
                entity.USER_DEF6       = model.USER_DEF6;
                entity.USER_DEF7       = model.USER_DEF7;
                entity.USER_DEF8       = model.USER_DEF8;
            }
            else
            {
                Type type  = typeof(Apps.Models.SCV.UPLOAD.UPLOAD_RECEIPT_CONTAINER_MODEL);
                Type typeE = typeof(Apps.Models.UPLOAD_RECEIPT_CONTAINER);
                foreach (var item in updateProperties)
                {
                    System.Reflection.PropertyInfo pi  = type.GetProperty(item);
                    System.Reflection.PropertyInfo piE = typeE.GetProperty(item);
                    piE.SetValue(entity, pi.GetValue(model), null);
                }
            }


            m_Rep.Modify(entity, updateProperties);
        }
示例#26
0
        // if 0, it's the SpawnList, 1 SpawnTimerList, 2 GroundItemList

        public ListViewPanel(int listType)
        {
            ListType = listType; // 0 = spawn list, 1 = spawn timer list, 2 = ground spawn list

            InitializeComponent();
            Font = new Font(Settings.Default.ListFont.FontFamily, Settings.Default.ListFont.Size, Settings.Default.ListFont.Style);

            if (listType == 0) // Add Columns to Spawnlist window
            {
                ColumnsAdd("Name", Settings.Default.c1w, HorizontalAlignment.Left);
                ColumnsAdd("Level", Settings.Default.c2w, HorizontalAlignment.Left);
                ColumnsAdd("Class", Settings.Default.c3w, HorizontalAlignment.Left);
                ColumnsAdd("Primary", Settings.Default.c3w, HorizontalAlignment.Left);
                ColumnsAdd("Offhand", Settings.Default.c3w, HorizontalAlignment.Left);
                ColumnsAdd("Race", Settings.Default.c4w, HorizontalAlignment.Left);
                ColumnsAdd("Owner", Settings.Default.c4w, HorizontalAlignment.Left);
                ColumnsAdd("Last Name", Settings.Default.c5w, HorizontalAlignment.Left);
                ColumnsAdd("Type", Settings.Default.c6w, HorizontalAlignment.Left);
                ColumnsAdd("Invis", Settings.Default.c7w, HorizontalAlignment.Left);
                ColumnsAdd("Run Speed", Settings.Default.c8w, HorizontalAlignment.Left);
                ColumnsAdd("SpawnID", Settings.Default.c9w, HorizontalAlignment.Left);
                ColumnsAdd("Spawn Time", Settings.Default.c10w, HorizontalAlignment.Left);
                ColumnsAdd("X", Settings.Default.c11w, HorizontalAlignment.Left);
                ColumnsAdd("Y", Settings.Default.c12w, HorizontalAlignment.Left);
                ColumnsAdd("Z", Settings.Default.c13w, HorizontalAlignment.Left);
                ColumnsAdd("Distance", Settings.Default.c14w, HorizontalAlignment.Left);
                //            SpawnList.ColumnsAdd("Guild", Settings.Default.c14w, HorizontalAlignment.Left); //17
            }
            else if (listType == 1)     // Add the Columns to the Spawn Timer Window
            {
                ColumnsAdd("Spawn Name", Settings.Default.c1w, HorizontalAlignment.Left);
                ColumnsAdd("Remain", Settings.Default.c10w, HorizontalAlignment.Left);
                ColumnsAdd("Interval", Settings.Default.c10w, HorizontalAlignment.Left);
                ColumnsAdd("Zone", Settings.Default.c10w, HorizontalAlignment.Left);
                ColumnsAdd("X", Settings.Default.c12w, HorizontalAlignment.Left);
                ColumnsAdd("Y", Settings.Default.c11w, HorizontalAlignment.Left);
                ColumnsAdd("Z", Settings.Default.c13w, HorizontalAlignment.Left);
                ColumnsAdd("Count", Settings.Default.c9w, HorizontalAlignment.Left);
                ColumnsAdd("Spawn Time", Settings.Default.c10w, HorizontalAlignment.Left);
                ColumnsAdd("Kill Time", Settings.Default.c10w, HorizontalAlignment.Left);
                ColumnsAdd("Next Spawn", Settings.Default.c10w, HorizontalAlignment.Left);
            }

            else if (listType == 2)     // Add Columns to Ground Items window
            {
                ColumnsAdd("Description", Settings.Default.c1w, HorizontalAlignment.Left);
                ColumnsAdd("Name", Settings.Default.c1w, HorizontalAlignment.Left);
                ColumnsAdd("Spawn Time", Settings.Default.c10w, HorizontalAlignment.Left);
                ColumnsAdd("X", Settings.Default.c12w, HorizontalAlignment.Left);
                ColumnsAdd("Y", Settings.Default.c11w, HorizontalAlignment.Left);
                ColumnsAdd("Z", Settings.Default.c13w, HorizontalAlignment.Left);
            }

            DoubleBuffered = true;

            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            // Use reflection to set the ListView control to being double buffered.  This stops the blinking.
            System.Reflection.PropertyInfo listProperty = typeof(Control).GetProperty("DoubleBuffered", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
            listProperty.SetValue(listView, true, null);
        }
示例#27
0
 public void Redo()
 {
     Property.SetValue(Source, NewValue);
     OnChange?.Invoke(this, EventArgs.Empty);
 }
示例#28
0
        public void loadDatas()
        {
            List <TblFgwj> items = new List <TblFgwj>();

            //读取整张表
            DataTable dataTable = sqlite.SelectFullTable("tbl_fgwj");

            if (dataTable != null)
            {
                int count = dataTable.Columns.Count;


                foreach (DataRow mDr in dataTable.Rows)
                {
                    TblFgwj item = new TblFgwj();
                    Type    type = item.GetType();

                    foreach (DataColumn mDc in dataTable.Columns)
                    {
                        /*
                         * string value = (mDr[mDc.ColumnName].Equals(DBNull.Value)) ? "" : (String)mDr[mDc.ColumnName];
                         * MyStringUtil.SetModelValue(mDc.ColumnName, value, item);
                         */


                        string propertyName = MyStringUtil.getCamelName(mDc.ColumnName);
                        System.Reflection.PropertyInfo propertyInfo = type.GetProperty(propertyName);

                        if (propertyInfo != null)
                        {
                            string value = (mDr[mDc.ColumnName].Equals(DBNull.Value)) ? "" : (String)mDr[mDc.ColumnName];
                            propertyInfo.SetValue(item, value, null); //给对应属性赋值
                        }
                    }

                    string[] result = ObjectUtils.GetModelProperties(item);

                    object[] result2 = ObjectUtils.GetModelValues(item);

                    /*
                     * item.idKey   = (mDr["ID_KEY"].Equals(DBNull.Value)) ? "" : (String)mDr["ID_KEY"];
                     * item.fileNo = (mDr["FILE_NO"].Equals(DBNull.Value)) ? "" : (String)mDr["FILE_NO"];
                     * item.subject = (mDr["SUBJECT"].Equals(DBNull.Value)) ? "" : (String)mDr["SUBJECT"];
                     * item.publishDate = (mDr["PUBLISH_DATE"].Equals(DBNull.Value)) ? "" : (String)mDr["PUBLISH_DATE"];
                     * item.implementDate = (mDr["IMPLEMENT_DATE"].Equals(DBNull.Value)) ? "" : (String)mDr["IMPLEMENT_DATE"];
                     **/

                    item.entityState = EntityState.NONE;
                    items.Add(item);
                }
            }

            /*
             * while (reader.Read())
             * {
             *  TblFgwj item = new TblFgwj();
             *  item.idKey = reader.GetString(reader.GetOrdinal("ID_KEY"));
             *  item.fileNo = reader.GetString(reader.GetOrdinal("FILE_NO"));
             *  item.subject = reader.GetString(reader.GetOrdinal("SUBJECT"));
             *  item.publishDate = reader.GetString(reader.GetOrdinal("PUBLISH_DATE"));
             *  item.implementDate = reader.GetString(reader.GetOrdinal("IMPLEMENT_DATE"));
             * }
             */

            //dataGrid.ItemsSource = dataTable.DefaultView;

            dataGrid.ItemsSource = items;

            Dictionary <String, String> columnLabels = sqlite.getColumns("TBL_FGWJ");
            //dataGrid.Columns.d

            /*
             * foreach (DataColumn column in dataTable.Columns){
             *  if (columnLabels.ContainsKey(column.ColumnName))
             *      column.ColumnName = columnLabels[column.ColumnName];
             * }*/
        }
示例#29
0
 /// <summary>
 /// コントロールの DoubleBuffered を設定します。
 /// </summary>
 /// <param name="control">対象となるコントロール。</param>
 /// <param name="flag">設定するフラグ。既定では true です。</param>
 public static void SetDoubleBuffered(System.Windows.Forms.Control control, bool flag = true)
 {
     System.Reflection.PropertyInfo prop = control.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
     prop.SetValue(control, flag, null);
 }
        protected virtual void SetDecimalValue(System.Reflection.PropertyInfo propertyInfo, object owner)
        {
            int value = new Random(randomIndex++).Next(0, 9999);

            propertyInfo.SetValue(owner, (decimal)value, null);
        }