Exemplo n.º 1
0
 public List<SMSSendInfo> Get(string com)
 {
     List<SMSSendInfo> list = new List<SMSSendInfo>();
     DataValues whereArgs = new DataValues();
     whereArgs.Add("com",com);
     whereArgs.Add("dateTime",DateTime.Now.Ticks);
     whereArgs.Add("state", 0);
     using (Cursor cursor = _dbHelper.Query(SMS_SEND, null, "com = ?,dateTime < ?,state = ?", null))
     {
         while (cursor.Next())
         {
             int sid = cursor.GetInt("sid");
             string phone = cursor.GetString("phone");
             string content = cursor.GetString("content");
             //int state = Convert.ToInt32(row["state"]);
             //model
             SMSSendInfo sendInfo = new SMSSendInfo
             {
                 Id = sid,
                 Com = com,
                 Phone = phone,
                 Message = content,
                 DateTime = DateTime.Now.Ticks,
             };
             list.Add(sendInfo);
             Set(sendInfo, 1);
         }
     }
     return list;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 添加数据点
        /// </summary>
        /// <param name="dateTime"></param>
        /// <param name="value"></param>
        public void AddPoint(DateTime dateTime, double value)
        {
            if (++Count > _maximumCount)
            {
                Count = _maximumCount;

                Labels.RemoveAt(0);
                UpperValues.RemoveAt(0);
                LowerValues.RemoveAt(0);
                DataValues.RemoveAt(0);
                CPKValues.RemoveAt(0);
            }

            Labels.Add(dateTime.ToString(GlobalConstants.TimeFormat));
            tbOdValue.Text = value.ToString(GlobalConstants.DoubleFormat);
            UpperValues.Add(_upper);
            LowerValues.Add(_lower);
            DataValues.Add(double.Parse(value.ToString(GlobalConstants.DoubleFormat)));

            if (Values.Count >= CPKCount)
            {
                Values.RemoveAt(0);
            }
            Values.Add(value);
            CPK             = CalculateCPK();
            tbCpkValue.Text = _cpk.ToString(GlobalConstants.DoubleFormat);
            CPKValues.Add(Math.Round(_cpk, 3));
        }
Exemplo n.º 3
0
        public void MsSqlTest()
        {
            IDbHelper dbHelper = new MsSQL("test");

            //dbHelper.CreateTable("TEST", tableValues);

            for (int i = 0; i < 10; i++)
            {
                DataValues contentValues = new DataValues();
                contentValues.Add("Name", "lsong");
                contentValues.Add("Password", "123456");
                int insert = dbHelper.Insert("myTable", contentValues);
                Assertion.Assert(insert <= 0);
            }

            using (TransactionScope transactionScope = new TransactionScope())
            {
                DataValues contentValues = new DataValues();
                dbHelper.Update("myTable", contentValues, null, null);

                transactionScope.Complete();
            }
            using (var cursor = dbHelper.Query("myTable", null, null, null))
            {
                while (cursor.Next())
                {
                    System.Console.Write(cursor[0] + "\t");
                    System.Console.Write(cursor[1] + "\t");
                    System.Console.Write(cursor[2] + "\t");
                    System.Console.WriteLine();
                }
            }
        }
Exemplo n.º 4
0
        public StaticDataHandler()
        {
            try
            {
                // Load existing data values from embedded resource.
                var serializer = new JsonSerializer();
                var assembly   = typeof(Extractor).Assembly;

                using (var stream = assembly.GetManifestResourceStream("RaidExtractor.Core.datavalues.json"))
                    using (var sr = new StreamReader(stream))
                        using (var textReader = new JsonTextReader(sr))
                        {
                            CurrentData = serializer.Deserialize <DataValues>(textReader);
                        }

                SetVariable("ExpectedRaidVersion", CurrentData.Version);
                foreach (DataValue v in CurrentData.Values)
                {
                    SetVariable(v.Name, v.Value);
                }
            }
            catch
            {
#if !DEV_BUILD
                // Don't throw exception for dev build as we can generate new values.
                throw new Exception("Unable to load static data values.");
#endif
            }
        }
Exemplo n.º 5
0
        private void AddNew()
        {
            const string defaultKeyName = "New Key";

            var keyName = defaultKeyName;

            if (DataValues.Any(k => k.RawKey == keyName))
            {
                var existingSameKey = DataValues.Where(k => k.RawKey.StartsWith(defaultKeyName))
                                      .Select(k => k.RawKey.Replace(defaultKeyName, String.Empty)).Select(
                    k =>
                {
                    if (int.TryParse(k, out var value))
                    {
                        return(value);
                    }

                    return(0);
                }
                    ).Max() + 1;

                keyName = defaultKeyName + existingSameKey.ToString();
            }

            DataValues.Add(new EncryptedKeyPair(Algorithm)
            {
                RawKey = keyName, RawValue = "New Value"
            });
        }
Exemplo n.º 6
0
 private void SetCustomIonFragmentInfo(SkylineDocumentProto.Types.Transition transitionProto)
 {
     if (Transition.IsNonReporterCustomIon())
     {
         transitionProto.Formula = DataValues.ToOptional(Transition.CustomIon.Formula);
         if (Transition.CustomIon.AverageMass.IsMassH())
         {
             transitionProto.AverageMassH = DataValues.ToOptional(Transition.CustomIon.AverageMass);
         }
         else
         {
             transitionProto.AverageMass = DataValues.ToOptional(Transition.CustomIon.AverageMass);
         }
         if (Transition.CustomIon.MonoisotopicMass.IsMassH())
         {
             transitionProto.MonoMassH = DataValues.ToOptional(Transition.CustomIon.MonoisotopicMass);
         }
         else
         {
             transitionProto.MonoMass = DataValues.ToOptional(Transition.CustomIon.MonoisotopicMass);
         }
         transitionProto.CustomIonName = DataValues.ToOptional(Transition.CustomIon.Name);
         transitionProto.MoleculeId    = DataValues.ToOptional(Transition.CustomIon.AccessionNumbers.ToString());
     }
     else
     {
         transitionProto.MeasuredIonName = DataValues.ToOptional(Transition.CustomIon.Name);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// CreateInsertSQL
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="contentValues"></param>
        /// <returns></returns>
        public string CreateInsertSQL(string tableName, DataValues contentValues)
        {
            StringBuilder stringBuilder = new StringBuilder("INSERT INTO");

            stringBuilder.Append(" ");
            if (String.IsNullOrEmpty(tableName))
            {
                throw new ArgumentException("tableName");
            }
            stringBuilder.AppendFormat("[{0}]", tableName);

            if (contentValues == null || contentValues.Count == 0)
            {
                throw new ArgumentException("contentValues");
            }
            string[]      keys     = contentValues.Keys;
            StringBuilder kBuilder = new StringBuilder();
            StringBuilder vBuilder = new StringBuilder();

            for (int i = 0; i < keys.Length; i++)
            {
                string key = keys[i];
                kBuilder.AppendFormat("[{0}]", key);
                vBuilder.AppendFormat("{0}", contentValues.Get(key));
                if ((i + 1) < keys.Length)
                {
                    kBuilder.Append(",");
                    vBuilder.Append(",");
                }
            }
            stringBuilder.AppendFormat("({0})", kBuilder);
            stringBuilder.AppendFormat("VALUES({0})", vBuilder);
            stringBuilder.Append(";");
            return(stringBuilder.ToString());
        }
Exemplo n.º 8
0
        private bool LoadDataFromStream(Stream stream)
        {
            try
            {
                var serializer = new JsonSerializer();
                var assembly   = typeof(Extractor).Assembly;

                CurrentData = null;
                using (var sr = new StreamReader(stream))
                    using (var textReader = new JsonTextReader(sr))
                    {
                        CurrentData = serializer.Deserialize <DataValues>(textReader);
                    }

                SetVariable("ExpectedRaidVersion", CurrentData.Version);
                foreach (DataValue v in CurrentData.Values)
                {
                    SetVariable(v.Name, v.Value);
                }

                stream.Dispose();

                return(true);
            }
            catch
            {
                stream.Dispose();

                return(false);
            }
        }
Exemplo n.º 9
0
    public string Save()
    {
        //Create a new instance of the BinaryFormatter
        BinaryFormatter binary = new BinaryFormatter();
        //Create a new instance of the SurrogateSelector
        SurrogateSelector surrogate = new SurrogateSelector();
        //Create a new file on the path
        FileStream fStream = File.Create(path);

        //Add out custom surrogates to the Surrogate
        Surrogates.AddSurrogates(ref surrogate);
        //Add the surrogates to the BinaryFormatter
        binary.SurrogateSelector = surrogate;

        //Create a new instance of the DataValues script
        DataValues saver = new DataValues();

        //Set all the values you want to save
        saver.Hours       = dateLogic.Hours;
        saver.Minutes     = dateLogic.Minutes;
        saver.Day         = dateLogic.Day;
        saver.Month       = dateLogic.Month;
        saver.Year        = dateLogic.Year;
        saver.GameObjects = collectObjects.collect();
        saver.Keywords    = keywords.Keywords;

        //Serialize the saverinstance to the fstream
        binary.Serialize(fStream, saver);
        //Close the stream
        fStream.Close();
        return("Successfully saved your data!");
    }
Exemplo n.º 10
0
    public string load()
    {
        if (File.Exists(path))
        {
            BinaryFormatter binary  = new BinaryFormatter();
            FileStream      fStream = File.Open(path, FileMode.Open);

            SurrogateSelector surrogater = new SurrogateSelector();
            Surrogates.AddSurrogates(ref surrogater);
            binary.SurrogateSelector = surrogater;

            DataValues saver = (DataValues)binary.Deserialize(fStream);
            fStream.Close();

            dateLogic.Hours   = saver.Hours;
            dateLogic.Minutes = saver.Minutes;
            dateLogic.Day     = saver.Day;
            dateLogic.Month   = saver.Month;
            dateLogic.Year    = saver.Year;
            keywords.Keywords = saver.Keywords;
            objects.loadObjects(saver.GameObjects);
            return("Successfully Loaded your data!\n");
        }
        return("Could not find the data, have you saved before?");
    }
Exemplo n.º 11
0
        public async Task <Instance> UpdateDataValues(
            [FromRoute] int instanceOwnerPartyId,
            [FromRoute] Guid instanceGuid,
            [FromBody] DataValues dataValues)
        {
            var      instanceId = $"{instanceOwnerPartyId}/{instanceGuid}";
            Instance instance   = await _instanceRepository.GetOne(instanceId, instanceOwnerPartyId);

            if (instance.DataValues == null)
            {
                instance.DataValues = new Dictionary <string, string>();
            }

            foreach (KeyValuePair <string, string> entry in dataValues.Values)
            {
                if (string.IsNullOrEmpty(entry.Value))
                {
                    instance.DataValues.Remove(entry.Key);
                }
                else
                {
                    instance.DataValues[entry.Key] = entry.Value;
                }
            }

            var updatedInstance = await _instanceRepository.Update(instance);

            return(updatedInstance);
        }
Exemplo n.º 12
0
        /// <inheritdoc />
        public IEnumerable <KeyValuePair <string, string> > GetById(Guid id)
        {
            var items     = new List <KeyValuePair <string, string> >();
            var dataValue = DataValues.Retrieve(id);

            if (dataValue == null)
            {
                return(items);
            }

            // Extract list items from the data value.
            var kind = DataValueKindCollection.FirstOrDefault(x => x.Id == dataValue.KindId);

            // Check type of collection returned by the data value kind.
            if (kind is IGetValueAndLabelCollection pairCollection)
            {
                // Create drop down items from values and labels.
                var pairs = pairCollection.GetValues(dataValue.Data);
                items.AddRange(pairs.Select(x => new KeyValuePair <string, string>(x.Label, x.Value)));
            }
            else if (kind is IGetStringCollection stringCollection)
            {
                // Create drop down items from strings.
                var strings = stringCollection.GetValues(dataValue.Data);
                items.AddRange(strings.Select(x => new KeyValuePair <string, string>(x, x)));
            }

            return(items);
        }
 /// <summary>
 /// Deletes the specified entity.
 /// </summary>
 /// <param name="entity">
 /// The entity to delete.
 /// </param>
 public void DeleteEntity(IEntity entity)
 {
     // Delete entity based on the entity type.
     if (entity is Form)
     {
         Forms.Delete(entity.Id);
     }
     else if (entity is Layout)
     {
         Layouts.Delete(entity.Id);
     }
     else if (entity is Validation)
     {
         Validations.Delete(entity.Id);
     }
     else if (entity is DataValue)
     {
         DataValues.Delete(entity.Id);
     }
     else if (entity is Folder)
     {
         Folders.Delete(entity.Id);
     }
     else if (entity is ConfiguredForm)
     {
         ConfiguredForms.Delete(entity.Id);
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// CreateUpdateSQL
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="values"></param>
        /// <param name="whereSql"></param>
        /// <param name="whereArgs"></param>
        /// <returns></returns>
        public string CreateUpdateSQL(string tableName, DataValues values, string whereSql, DataValues whereArgs)
        {
            StringBuilder stringBuilder = new StringBuilder("UPDATE");

            stringBuilder.Append(" ");
            stringBuilder.AppendFormat("[{0}]", tableName);
            string[] keys = values.Keys;
            if (keys == null || keys.Length == 0)
            {
                throw new ArgumentException("values");
            }
            stringBuilder.Append(" ");
            stringBuilder.Append("SET");
            stringBuilder.Append(" ");
            for (int i = 0; i < values.Count; i++)
            {
                string key = keys[i];
                stringBuilder.AppendFormat("[{0}] = {1}", key, values.Get(key));
                if ((i + 1) < keys.Length)
                {
                    stringBuilder.Append(",");
                }
            }
            if (!String.IsNullOrEmpty(whereSql))
            {
                whereSql = CreateWhereSql(whereSql, whereArgs);
                stringBuilder.Append(" ");
                stringBuilder.Append(whereSql);
            }
            stringBuilder.Append(";");
            return(stringBuilder.ToString());
        }
Exemplo n.º 15
0
        //This method send messages to topic "test"
        static void SimulatePublish()
        {
            DataValues dataV = new DataValues();

            dataV.Camera  = "Cam10";
            dataV.Date    = DateTime.UtcNow;
            dataV.Status  = "Online";
            dataV.Product = new string[] { "Beer", "Heineken", "Bottle" };

            string json = JsonConvert.SerializeObject(dataV);

            var counter = 0;

            while (counter < 10)
            {
                counter++;
                var testMessage = new MqttApplicationMessageBuilder()
                                  .WithTopic("EmptyDetection")
                                  .WithPayload($" {json}")
                                  .WithExactlyOnceQoS()
                                  .WithRetainFlag()
                                  .Build();


                if (_client.IsConnected)
                {
                    Console.WriteLine($"publishing at {DateTime.UtcNow}");
                    _client.PublishAsync(testMessage);
                }
                Thread.Sleep(2000);
            }
        }
Exemplo n.º 16
0
        public List <SMSSendInfo> Get(string com)
        {
            List <SMSSendInfo> list      = new List <SMSSendInfo>();
            DataValues         whereArgs = new DataValues();

            whereArgs.Add("com", com);
            whereArgs.Add("dateTime", DateTime.Now.Ticks);
            whereArgs.Add("state", 0);
            using (Cursor cursor = _dbHelper.Query(SMS_SEND, null, "com = ?,dateTime < ?,state = ?", null))
            {
                while (cursor.Next())
                {
                    int    sid     = cursor.GetInt("sid");
                    string phone   = cursor.GetString("phone");
                    string content = cursor.GetString("content");
                    //int state = Convert.ToInt32(row["state"]);
                    //model
                    SMSSendInfo sendInfo = new SMSSendInfo
                    {
                        Id       = sid,
                        Com      = com,
                        Phone    = phone,
                        Message  = content,
                        DateTime = DateTime.Now.Ticks,
                    };
                    list.Add(sendInfo);
                    Set(sendInfo, 1);
                }
            }
            return(list);
        }
        public async Task <ActionResult <Instance> > UpdateDataValues(
            [FromRoute] int instanceOwnerPartyId,
            [FromRoute] Guid instanceGuid,
            [FromBody] DataValues dataValues)
        {
            if (dataValues?.Values == null)
            {
                return(BadRequest($"Missing parameter value: dataValues is misformed or empty"));
            }

            var      instanceId = $"{instanceOwnerPartyId}/{instanceGuid}";
            Instance instance   = await _instanceRepository.GetOne(instanceId, instanceOwnerPartyId);

            instance.DataValues ??= new Dictionary <string, string>();

            foreach (KeyValuePair <string, string> entry in dataValues.Values)
            {
                if (string.IsNullOrEmpty(entry.Value))
                {
                    instance.DataValues.Remove(entry.Key);
                }
                else
                {
                    instance.DataValues[entry.Key] = entry.Value;
                }
            }

            var updatedInstance = await _instanceRepository.Update(instance);

            return(Ok(updatedInstance));
        }
Exemplo n.º 18
0
        public void MsSqlTest()
        {
            IDbHelper dbHelper = new MsSQL("test");
            //dbHelper.CreateTable("TEST", tableValues);

            for (int i = 0; i < 10; i++)
            {
                DataValues contentValues = new DataValues();
                contentValues.Add("Name", "lsong");
                contentValues.Add("Password", "123456");
                int insert = dbHelper.Insert("myTable", contentValues);
                Assertion.Assert(insert <= 0);
            }

            using (TransactionScope transactionScope = new TransactionScope())
            {
                DataValues contentValues = new DataValues();
                dbHelper.Update("myTable", contentValues, null, null);

                transactionScope.Complete();
            }
            using (var cursor = dbHelper.Query("myTable", null, null, null))
            {
                while (cursor.Next())
                {
                    System.Console.Write(cursor[0] + "\t");
                    System.Console.Write(cursor[1] + "\t");
                    System.Console.Write(cursor[2] + "\t");
                    System.Console.WriteLine();
                }
            }
        }
Exemplo n.º 19
0
        public bool UpdateValuesFromGame(string exePath)
        {
#if DEV_BUILD
            Il2Cpp         il2Cpp;
            Il2CppExecutor executor;
            Metadata       metadata;

            string il2CppPath;
            string metadataPath;

            string[] pathParts = exePath.Split('\\');
            string   version   = "\\" + pathParts[pathParts.Length - 2] + "\\";
            SetVariable("ExpectedRaidVersion", version);

            if (!FindGameFiles(Directory.GetParent(exePath).FullName, out il2CppPath, out metadataPath))
            {
                throw new Exception("Failed to find the game files.");
            }

            if (!ExtractCurrentData(il2CppPath, metadataPath, out il2Cpp, out executor, out metadata))
            {
                throw new Exception("Failed to extract the data from the game.");
            }

            DataValues newValues = new DataValues();
            newValues.Version = version;
            newValues.Values  = new List <DataValue>();
            foreach (GameDataEntry entry in SearchEntries)
            {
                switch (entry.Type)
                {
                case GameDataEntry.DataType.FieldOffset:
                    SetVariable(entry.Name, GetFieldOffset(il2Cpp, metadata, executor, entry.ClassName, entry.MemberName));
                    break;

                case GameDataEntry.DataType.SystemMethod:
                    SetVariable(entry.Name, GetMethodAddress(il2Cpp, metadata, executor, entry.ClassName, entry.MemberName));
                    break;

                case GameDataEntry.DataType.SystemType:
                    SetVariable(entry.Name, GetTypeInfoAddress(il2Cpp, metadata, executor, entry.MemberName));
                    break;
                }

                DataValue v = new DataValue();
                v.Name  = entry.Name;
                v.Value = (int)GetValue(entry.Name);
                newValues.Values.Add(v);
            }

            string filename = GetDataValuesPath();
            File.WriteAllText(filename, JsonConvert.SerializeObject(newValues, SerializerSettings));
            Console.WriteLine("Written class data to " + filename + ". Copy to porject directory before rebuilding.");

            return(true);
#else
            return(false);
#endif
        }
Exemplo n.º 20
0
 public void AddItem(VAR var)
 {
     lock (_enable)
     {
         DataValues.Add(var);
     }
     Save();
 }
Exemplo n.º 21
0
        private object[,] GetAllValues()
        {
            var result = new object[DataValues.GetLength(0) + 1, HeaderValues.Length];

            CoyyHeadersInToResult(result);
            CopyDataToResult(result);
            return(result);
        }
Exemplo n.º 22
0
 public void RemoveItem(VAR var)
 {
     lock (_enable)
     {
         DataValues.Remove(var);
     }
     Save();
 }
Exemplo n.º 23
0
 public void AddDataValue(DataValue dv)
 {
     if (DataValues.Any(x => x == dv))
     {
         throw new ArgumentException("Duplicate Value.");
     }
     ((List <DataValue>)DataValues).Add(dv);
 }
Exemplo n.º 24
0
 public void Set(SMSSendInfo sendInfo, int state)
 {
     DataValues contentValues = new DataValues();
     contentValues.Add("state", state);
     DataValues whereArgs = new DataValues();
     whereArgs.Add("SID", sendInfo.Id);
     _dbHelper.Update(SMS_SEND, contentValues, "SID = ?", whereArgs);
 }
Exemplo n.º 25
0
        /// <summary>
        /// Deserialize the configuration for a checkbox list field.
        /// </summary>
        /// <param name="configuration">
        /// The serialized configuration.
        /// </param>
        /// <returns>
        /// The deserialized configuration.
        /// </returns>
        public object DeserializeConfiguration(string configuration)
        {
            // Variables.
            var items  = new List <CheckboxListItem>();
            var config = new CheckboxListConfiguration()
            {
                Items = items
            };
            var configData    = JsonHelper.Deserialize <JObject>(configuration);
            var dynamicConfig = configData as dynamic;
            var properties    = configData.Properties().Select(x => x.Name);
            var propertySet   = new HashSet <string>(properties);


            // A data value is selected?
            if (propertySet.Contains("dataValue"))
            {
                // Get info about the data value.
                var dataValueId = GuidHelper.GetGuid(dynamicConfig.dataValue.Value as string);
                var dataValue   = DataValues.Retrieve(dataValueId);
                if (dataValue != null)
                {
                    // Extract list items from the data value.
                    var kind             = DataValueKindCollection.FirstOrDefault(x => x.Id == dataValue.KindId);
                    var pairCollection   = kind as IGetValueAndLabelCollection;
                    var stringCollection = kind as IGetStringCollection;


                    // Check type of collection returned by the data value kind.
                    if (pairCollection != null)
                    {
                        // Create checkboxes from values and labels.
                        var pairs = pairCollection.GetValues(dataValue.Data);
                        items.AddRange(pairs.Select(x => new CheckboxListItem()
                        {
                            Selected = false,
                            Value    = x.Value,
                            Label    = x.Label
                        }));
                    }
                    else if (stringCollection != null)
                    {
                        // Create checkboxes from strings.
                        var strings = stringCollection.GetValues(dataValue.Data);
                        items.AddRange(strings.Select(x => new CheckboxListItem()
                        {
                            Selected = false,
                            Value    = x,
                            Label    = x
                        }));
                    }
                }
            }


            // Return the data value configuration.
            return(config);
        }
Exemplo n.º 26
0
        private void FillAllValues()
        {
            _allValues = new string[DataValues.GetLength(0) + 1, DataValues.GetLength(1)];
            var numberOfColumns  = DataValues.GetLength(1);
            var NumberOfDataRows = DataValues.GetLength(0);

            FillHeaders(numberOfColumns);
            Array.Copy(DataValues, 0, _allValues, numberOfColumns, numberOfColumns * NumberOfDataRows);
        }
        public static async Task SeedAsync(SoccerFieldServerContext dbContext,
                                           UserManager <ApplicationUser> userManager,
                                           RoleManager <IdentityRole> roleManager,
                                           ILoggerFactory loggerFactory, int?retry = 0)
        {
            int retryForAvailability = retry.Value;

            try
            {
                dbContext.Database.Migrate();
                await AddData.SeedRolesAndClaims(userManager, roleManager);

                await AddData.SeedAdmin(userManager);

                await AddData.SeedOwner(userManager);

                await AddData.SeedStaff(userManager);

                await AddData.SeedCustomer(userManager);

                if (!dbContext.GroupSoccerFields.Any())
                {
                    dbContext.GroupSoccerFields.AddRange(DataValues.GroupSoccerFieldData());
                    await dbContext.SaveChangesAsync();
                }
                if (!dbContext.SoccerFields.Any())
                {
                    dbContext.SoccerFields.AddRange(DataValues.SoccerFieldData());
                    await dbContext.SaveChangesAsync();
                }
                if (!dbContext.Products.Any())
                {
                    dbContext.Products.AddRange(DataValues.ProductData());
                    await dbContext.SaveChangesAsync();
                }
                if (!dbContext.User_GroupSoccerFields.Any())
                {
                    dbContext.User_GroupSoccerFields.AddRange(DataValues.User_GroupSoccerFieldData());
                    await dbContext.SaveChangesAsync();
                }
                if (!dbContext.WorkScheduleStaffs.Any())
                {
                    dbContext.WorkScheduleStaffs.AddRange(DataValues.WorkScheduleStaffData());
                    await dbContext.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                if (retryForAvailability < 10)
                {
                    retryForAvailability++;
                    var log = loggerFactory.CreateLogger <SoccerFieldServerContext>();
                    log.LogError(ex.Message);
                    await SeedAsync(dbContext, userManager, roleManager, loggerFactory, retryForAvailability);
                }
            }
        }
        private void CartesianChart_DataClick(object sender, ChartPoint chartpoint)
        {
            Console.WriteLine("clicked!");
            Random r = new Random();
            var    n = DataValues.Count;

            DataValues.Clear();
            DataValues.AddRange(new double[n].Select(_ => r.Next(60) / 1.0));
        }
Exemplo n.º 29
0
 // ZedGraph ignores points with double.NaN so invalid value must set to this.
 private double[] MakeChartValue(DataValues dv)
 {
     double[] retList = new double[dv.Count];
     for (int idx = 0; idx < dv.Count; idx++)
     {
         retList[idx] = (idx < dv.FirstValidValue?double.NaN:dv.Values[idx]);
     }
     return(retList);
 }
Exemplo n.º 30
0
 private void CopyDataToResult(object[,] result)
 {
     for (int row = 0; row < DataValues.GetLength(0); row++)
     {
         for (int col = 0; col < DataValues.GetLength(1); col++)
         {
             result[row + 1, col] = DataValues[row, col];
         }
     }
 }
 static void load()
 {
     if (File.Exists(Application.persistentDataPath + "/" + _SaveDataFileName + ".dat"))
     {
         BinaryFormatter bf   = new BinaryFormatter();
         FileStream      file = File.Open(Application.persistentDataPath + "/" + _SaveDataFileName + ".dat", FileMode.Open);
         dataValues = (DataValues)bf.Deserialize(file);
         file.Close();
     }
 }
Exemplo n.º 32
0
        public void Set(SMSSendInfo sendInfo, int state)
        {
            DataValues contentValues = new DataValues();

            contentValues.Add("state", state);
            DataValues whereArgs = new DataValues();

            whereArgs.Add("SID", sendInfo.Id);
            _dbHelper.Update(SMS_SEND, contentValues, "SID = ?", whereArgs);
        }
Exemplo n.º 33
0
 public SkylineDocumentProto.Types.TransitionLoss ToLossProto()
 {
     return(new SkylineDocumentProto.Types.TransitionLoss()
     {
         Formula = Formula,
         MonoisotopicMass = MonoisotopicMass,
         AverageMass = AverageMass,
         LossInclusion = DataValues.ToLossInclusion(Inclusion)
     });
 }
Exemplo n.º 34
0
 public long Add(SMSSendInfo smsInfo)
 {
     const int defaultNum = 0;
     DataValues contentValues = new DataValues();
     contentValues.Add("SID",null);
     contentValues.Add("COM",smsInfo.Com);
     contentValues.Add("PHONE",smsInfo.Phone);
     contentValues.Add("CONTENT",smsInfo.Message);
     contentValues.Add("DATETIME",smsInfo.DateTime);
     contentValues.Add("STATE",defaultNum);
     int result = _dbHelper.Insert(SMS_SEND, contentValues);
     return result;
 }
Exemplo n.º 35
0
        /// <summary>
        /// CreateWhereSql
        /// </summary>
        /// <param name="whereSql"></param>
        /// <param name="whereArgs"></param>
        /// <returns></returns>
        protected virtual string CreateWhereSql(string whereSql, DataValues whereArgs)
        {
            if (String.IsNullOrEmpty(whereSql))
            {
                throw new ArgumentException("whereSql");
            }

            StringBuilder stringBuilder = new StringBuilder("WHERE");
            string[] args = whereSql.Split(',', ';');
            if (args.Length > 0)
            {
                stringBuilder.Append(" ");
                for (int i = 0; i < args.Length; i++)
                {
                    string str = args[i];
                    string[] aa = str.Split('=', '<', '>');
                    string key = aa[0].Trim();
                    string value = aa[1].Trim();
                    if (Equals(value, "?"))
                    {
                        if (whereArgs == null || whereArgs.Count == 0)
                        {
                            throw new ArgumentException("contentValues");
                        }
                        value = whereArgs.Get(key);
                    }
                    stringBuilder.AppendFormat("[{0}] = {1}", key, value);
                    if ((i + 1) < args.Length)
                    {
                        stringBuilder.Append(" ");
                        stringBuilder.Append("and");
                        stringBuilder.Append(" ");
                    }
                }
            }
            return stringBuilder.ToString();
        }
Exemplo n.º 36
0
 /// <summary>
 /// CreateSelectSQL
 /// </summary>
 /// <param name="tableName"></param>
 /// <param name="columnNames"></param>
 /// <param name="whereSql"></param>
 /// <param name="whereArgs"></param>
 /// <returns></returns>
 protected virtual string CreateSelectSQL(string tableName, string[] columnNames, string whereSql, DataValues whereArgs)
 {
     StringBuilder stringBuilder = new StringBuilder("SELECT");
     stringBuilder.Append(" ");
     if (columnNames == null || columnNames.Length == 0)
     {
         stringBuilder.Append("*");
     }
     else
     {
         for (int i = 0; i < columnNames.Length; i++)
         {
             string columnName = columnNames[i];
             stringBuilder.AppendFormat("[{0}]", columnName);
             if ((i + 1) < columnNames.Length)
             {
                 stringBuilder.Append(",");
             }
         }
     }
     if (!String.IsNullOrEmpty(tableName))
     {
         stringBuilder.Append(" ");
         stringBuilder.Append("FROM");
         stringBuilder.Append(" ");
         stringBuilder.AppendFormat("[{0}]", tableName);
     }
     if (!String.IsNullOrEmpty(whereSql))
     {
         whereSql = CreateWhereSql(whereSql, whereArgs);
         stringBuilder.Append(" ");
         stringBuilder.Append(whereSql);
     }
     stringBuilder.Append(";");
     return stringBuilder.ToString();
 }
Exemplo n.º 37
0
 /// <summary>
 /// 根据指定的 tableName,values,whereSql  和 whereArgs  在 数据连接上执行更新操作
 /// </summary>
 /// <param name="tableName">tableName</param>
 /// <param name="values">values</param>
 /// <param name="whereSql">whereSql</param>
 /// <param name="whereArgs">whereArgs</param>
 /// <returns></returns>
 public virtual int Update(string tableName, DataValues values, string whereSql, DataValues whereArgs)
 {
     string sql = CreateUpdateSQL(tableName, values, whereSql, whereArgs);
     return ExecSql(sql);
 }
Exemplo n.º 38
0
 /// <summary>
 /// GetDataSet
 /// </summary>
 /// <param name="tableName"></param>
 /// <param name="columnNames"></param>
 /// <param name="whereSql"></param>
 /// <param name="whereArgs"></param>
 /// <returns></returns>
 public virtual DataSet GetDataSet(string tableName, string[] columnNames, string whereSql,DataValues whereArgs)
 {
     string sql = CreateSelectSQL(tableName, columnNames, whereSql, whereArgs);
     return GetDataSet(sql);
 }
Exemplo n.º 39
0
        /// <summary>
        /// The load ent controls.
        /// </summary>
        /// <param name="entArray">The ent array.</param>
        /// <remarks></remarks>
        private void LoadENTControls(object[] entArray)
        {
            this.selectedTagType = map.SelectedMeta.type;

            this.toolStripTagType.Text = "[" + this.selectedTagType + "]";
            this.toolStripTagName.Text = map.SelectedMeta.name;

            // this.Padding = new Padding(10);
            int colorSpaceCount = 4;

            // Custom Plugins access
            //ra = new RegistryAccess(
            //    Registry.CurrentUser,
            //    RegistryAccess.RegPaths.Halo2CustomPlugins + pluginName + "\\" + this.selectedTagType);
            //if (pluginName == null)
            //{
            //    ra.CloseReg();
            //}

            if (entArray != null)
                foreach (object o in entArray)
                {
                    IFPIO.BaseObject tempbase = (IFPIO.BaseObject)o;
                    if (tempbase.visible == false)
                    {
                        if (ShowInvisibles == false)
                        {
                            continue;
                        }
                    }

                    // skip hidden custom plugins variables (mark reflexives to be removed if empty)
                    bool skipEmptyReflex = false;
                    //if (ra.isOpen && ra.getValue(tempbase.offset.ToString()) == bool.FalseString)
                    //{
                    //    if (tempbase.ObjectType == IFPIO.ObjectEnum.Struct)
                    //    {
                    //        skipEmptyReflex = true;
                    //    }
                    //    else
                    //    {
                    //        continue;
                    //    }
                    //}

                    switch (tempbase.ObjectType)
                    {
                        case IFPIO.ObjectEnum.Struct:
                            {
                                if (ShowReflexives == false)
                                {
                                    break;
                                }

                                // tempLabel is a blank space located above reflexives
                                Label tempLabel = new Label();
                                tempLabel.AutoSize = true;
                                tempLabel.Location = new Point(0, 0);
                                tempLabel.Name = "label1";
                                tempLabel.Dock = DockStyle.Top;
                                tempLabel.Size = new Size(35, 13);
                                tempLabel.TabIndex = tabIndex;

                                // tempReflexive is the reflexive and all data (incl other reflexives) within it
                                ReflexiveControl tempReflexive = new ReflexiveControl(
                                    map,
                                    map.SelectedMeta.offset,
                                    ((IFPIO.Reflexive)tempbase).HasCount,
                                    tempbase.lineNumber,
                                    this);

                                // tempReflexive.Location = new System.Drawing.Point(10, 0);
                                tempReflexive.Name = "reflexive";
                                tempReflexive.TabIndex = tabIndex;
                                tempReflexive.LoadENTControls(
                                    (IFPIO.Reflexive)tempbase,
                                    ((IFPIO.Reflexive)tempbase).items,
                                    true,
                                    0,
                                    ref tabIndex,
                                    tempbase.offset.ToString());

                                // Label, Combobox & Button are always added ( = 3)
                                if (!(tempReflexive.Controls.Count <= 2 && skipEmptyReflex))
                                {
                                    this.Controls[0].Controls.Add(tempLabel);
                                    tempLabel.BringToFront();
                                    this.Controls[0].Controls.Add(tempReflexive);
                                    tempReflexive.BringToFront();
                                }

                                break;
                            }

                        case IFPIO.ObjectEnum.Ident:
                            {
                                if (ShowIdents == false)
                                {
                                    break;
                                }

                                Ident tempident = new Ident(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.Ident)tempbase).hasTagType,
                                    tempbase.lineNumber);
                                tempident.Name = "ident";
                                tempident.TabIndex = tabIndex;
                                tempident.Populate(map.SelectedMeta.offset);
                                tempident.Tag = "[" + tempident.Controls[2].Text + "] " + tempident.Controls[1].Text;
                                tempident.Controls[1].ContextMenuStrip = identContext;
                                this.Controls[0].Controls.Add(tempident);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.StringID:
                            {
                                if (ShowSIDs == false)
                                {
                                    break;
                                }

                                SID tempSID = new SID(tempbase.name, map, tempbase.offset, tempbase.lineNumber);
                                tempSID.Name = "sid";
                                tempSID.TabIndex = tabIndex;
                                tempSID.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempSID);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Float:
                            {
                                if (ShowFloats == false)
                                {
                                    break;
                                }

                                DataValues tempFloat = new DataValues(
                                    tempbase.name, map, tempbase.offset, IFPIO.ObjectEnum.Float, tempbase.lineNumber);
                                tempFloat.TabIndex = tabIndex;
                                tempFloat.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempFloat);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.String32:
                            {
                                if (ShowString32s == false && tempbase.ObjectType == IFPIO.ObjectEnum.String32)
                                {
                                    break;
                                }

                                EntStrings tempstring = new EntStrings(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.IFPString)tempbase).size,
                                    ((IFPIO.IFPString)tempbase).type,
                                    tempbase.lineNumber);
                                tempstring.Name = "string";
                                tempstring.TabIndex = tabIndex;
                                tempstring.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempstring);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.UnicodeString256:
                            {
                                if (ShowUnicodeString256s == false)
                                {
                                    break;
                                }

                                goto case IFPIO.ObjectEnum.String32;
                            }

                        case IFPIO.ObjectEnum.String256:
                            {
                                if (ShowString256s == false)
                                {
                                    break;
                                }

                                goto case IFPIO.ObjectEnum.String32;
                            }

                        case IFPIO.ObjectEnum.UnicodeString64:
                            {
                                if (ShowUnicodeString64s == false)
                                {
                                    break;
                                }

                                goto case IFPIO.ObjectEnum.String32;
                            }

                        case IFPIO.ObjectEnum.String:
                            {
                                if (ShowString32s == false && tempbase.ObjectType == IFPIO.ObjectEnum.String32)
                                {
                                    break;
                                }

                                EntStrings tempstring = new EntStrings(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.IFPString)tempbase).size,
                                    ((IFPIO.IFPString)tempbase).type,
                                    tempbase.lineNumber);
                                tempstring.Name = "string";
                                tempstring.TabIndex = tabIndex;
                                tempstring.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempstring);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Int:
                            {
                                if (((IFPIO.IFPInt)tempbase).entIndex.nulled)
                                {
                                    if ((ShowInts == false && tempbase.ObjectType == IFPIO.ObjectEnum.Int) ||
                                        (ShowShorts == false && tempbase.ObjectType == IFPIO.ObjectEnum.Short) ||
                                        (ShowUshorts == false && tempbase.ObjectType == IFPIO.ObjectEnum.UShort) ||
                                        (ShowUints == false && tempbase.ObjectType == IFPIO.ObjectEnum.UInt))
                                    {
                                        break;
                                    }

                                    DataValues tempdatavalues = new DataValues(
                                        tempbase.name, map, tempbase.offset, tempbase.ObjectType, tempbase.lineNumber);
                                    tempdatavalues.TabIndex = tabIndex;
                                    tempdatavalues.Populate(map.SelectedMeta.offset);
                                    this.Controls[0].Controls.Add(tempdatavalues);
                                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                }
                                else
                                {
                                    if ((ShowBlockIndex32s == false &&
                                         (tempbase.ObjectType == IFPIO.ObjectEnum.Int |
                                          tempbase.ObjectType == IFPIO.ObjectEnum.UInt)) ||
                                        (ShowBlockIndex16s == false &&
                                         (tempbase.ObjectType == IFPIO.ObjectEnum.Short |
                                          tempbase.ObjectType == IFPIO.ObjectEnum.UShort)) ||
                                        (ShowBlockIndex8s == false && tempbase.ObjectType == IFPIO.ObjectEnum.Byte))
                                    {
                                        break;
                                    }

                                    Indices tempdatavalues = new Indices(
                                        tempbase.name,
                                        map,
                                        tempbase.offset,
                                        tempbase.ObjectType,
                                        ((IFPIO.IFPInt)tempbase).entIndex);
                                    tempdatavalues.TabIndex = tabIndex;
                                    this.Controls[0].Controls.Add(tempdatavalues);
                                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                }

                                break;
                            }

                        case IFPIO.ObjectEnum.Short:
                            {
                                goto case IFPIO.ObjectEnum.Int;
                            }

                        case IFPIO.ObjectEnum.UShort:
                            {
                                goto case IFPIO.ObjectEnum.Int;
                            }

                        case IFPIO.ObjectEnum.UInt:
                            {
                                goto case IFPIO.ObjectEnum.Int;
                            }

                        case IFPIO.ObjectEnum.Unknown:
                            {
                                if (ShowUndefineds == false)
                                {
                                    break;
                                }

                                DataValues tempUnknown = new DataValues(
                                    tempbase.name, map, tempbase.offset, IFPIO.ObjectEnum.Unknown, tempbase.lineNumber);
                                tempUnknown.TabIndex = tabIndex;
                                tempUnknown.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempUnknown);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Byte_Flags:
                            {
                                if (ShowBitmask8s == false)
                                {
                                    break;
                                }

                                Bitmask tempbitmask = new Bitmask(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.Bitmask)tempbase).bitmaskSize,
                                    ((IFPIO.Bitmask)tempbase).options,
                                    tempbase.lineNumber);
                                tempbitmask.TabIndex = tabIndex;
                                tempbitmask.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempbitmask);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Word_Flags:
                            {
                                if (ShowBitmask16s == false)
                                {
                                    break;
                                }

                                Bitmask tempbitmask = new Bitmask(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.Bitmask)tempbase).bitmaskSize,
                                    ((IFPIO.Bitmask)tempbase).options,
                                    tempbase.lineNumber);
                                tempbitmask.TabIndex = tabIndex;
                                tempbitmask.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempbitmask);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Long_Flags:
                            {
                                if (ShowBitmask32s == false)
                                {
                                    break;
                                }

                                Bitmask tempbitmask = new Bitmask(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.Bitmask)tempbase).bitmaskSize,
                                    ((IFPIO.Bitmask)tempbase).options,
                                    tempbase.lineNumber);
                                tempbitmask.TabIndex = tabIndex;
                                tempbitmask.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempbitmask);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Char_Enum:
                            {
                                if (ShowEnum8s == false)
                                {
                                    break;
                                }

                                Enums tempenum = new Enums(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.IFPEnum)tempbase).enumSize,
                                    ((IFPIO.IFPEnum)tempbase).options,
                                    tempbase.lineNumber);
                                tempenum.TabIndex = tabIndex;
                                tempenum.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempenum);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Enum:
                            {
                                if (ShowEnum16s == false)
                                {
                                    break;
                                }

                                Enums tempenum = new Enums(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.IFPEnum)tempbase).enumSize,
                                    ((IFPIO.IFPEnum)tempbase).options,
                                    tempbase.lineNumber);
                                tempenum.TabIndex = tabIndex;
                                tempenum.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempenum);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Long_Enum:
                            {
                                if (ShowEnum32s == false)
                                {
                                    break;
                                }

                                Enums tempenum = new Enums(
                                    tempbase.name,
                                    map,
                                    tempbase.offset,
                                    ((IFPIO.IFPEnum)tempbase).enumSize,
                                    ((IFPIO.IFPEnum)tempbase).options,
                                    tempbase.lineNumber);
                                tempenum.TabIndex = tabIndex;
                                tempenum.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempenum);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.Byte:
                            {
                                if (((IFPIO.IFPByte)tempbase).entIndex.nulled)
                                {
                                    if (ShowBytes == false)
                                    {
                                        break;
                                    }

                                    DataValues tempByte = new DataValues(
                                        tempbase.name, map, tempbase.offset, IFPIO.ObjectEnum.Byte, tempbase.lineNumber);
                                    tempByte.TabIndex = tabIndex;
                                    this.Controls[0].Controls.Add(tempByte);
                                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                }
                                else
                                {
                                    if (ShowBlockIndex8s == false)
                                    {
                                        break;
                                    }

                                    Indices tempdatavalues = new Indices(
                                        tempbase.name,
                                        map,
                                        tempbase.offset,
                                        tempbase.ObjectType,
                                        ((IFPIO.IFPByte)tempbase).entIndex);
                                    tempdatavalues.TabIndex = tabIndex;
                                    this.Controls[0].Controls.Add(tempdatavalues);
                                    this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                }

                                break;
                            }

                        case IFPIO.ObjectEnum.Unused:
                            {
                                DataValues tempUnknown = new DataValues(
                                    tempbase.name, map, tempbase.offset, IFPIO.ObjectEnum.Unused, tempbase.lineNumber);
                                tempUnknown.TabIndex = tabIndex;
                                tempUnknown.Populate(map.SelectedMeta.offset);
                                this.Controls[0].Controls.Add(tempUnknown);
                                this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();
                                break;
                            }

                        case IFPIO.ObjectEnum.TagType:
                            continue;
                    }

                    if (!(tempbase is IFPIO.Reflexive))
                    {
                        ToolTip1.SetToolTip(this.Controls[0].Controls[0].Controls[0], "offset: " + tempbase.offset);
                    }

                    if (this.Controls[0].Controls.Count > 0 && this.Controls[0].Controls[0] is DataValues)
                    {
                        // if (((tempbase.name.ToLower().Contains(" a") & tempbase.name[tempbase.name.ToLower().IndexOf(" a")]) ||
                        // tempbase.name.ToLower().Contains("alpha"))& alphaControl == null)
                        if (ColorWheel.checkForColor(tempbase.name, alphaControl, " a", "alpha"))
                        {
                            alphaControl = (DataValues)this.Controls[0].Controls[0];
                            colorSpaceCount = 0;
                        }

                            // if (tempbase.name.ToLower().Contains(" r") & redControl == null)
                        else if (ColorWheel.checkForColor(tempbase.name, redControl, " r", "red"))
                        {
                            redControl = (DataValues)this.Controls[0].Controls[0];
                            colorSpaceCount = 0;
                        }

                            // if (tempbase.name.ToLower().Contains(" g") & greenControl == null)
                        else if (ColorWheel.checkForColor(tempbase.name, greenControl, " g", "green"))
                        {
                            greenControl = (DataValues)this.Controls[0].Controls[0];
                            colorSpaceCount = 0;
                        }

                            // if (tempbase.name.ToLower().Contains(" b") & blueControl == null)
                        else if (ColorWheel.checkForColor(tempbase.name, blueControl, " b", "blue"))
                        {
                            blueControl = (DataValues)this.Controls[0].Controls[0];
                            colorSpaceCount = 0;
                        }
                        else
                        {
                            colorSpaceCount++;
                            if (colorSpaceCount == 1)
                            {
                                alphaControl = null;
                                redControl = null;
                                greenControl = null;
                                blueControl = null;
                            }
                        }

                        if (redControl != null & greenControl != null & blueControl != null)
                        {
                            // Create the new ColorWheel class, indicating
                            // the locations of the color wheel itself, the
                            // brightness area, and the position of the selected color.
                            ColorWheel cw = new ColorWheel();

                            if (alphaControl != null)
                            {
                                cw.setTextBox(alphaControl.textBox1, Color.White);
                            }

                            cw.setTextBox(redControl.textBox1, Color.Red);
                            cw.setTextBox(greenControl.textBox1, Color.Green);
                            cw.setTextBox(blueControl.textBox1, Color.Blue);

                            // p.I.AddRange(new Rectangle[] { SelectedColorRectangle });
                            cw.Dock = DockStyle.Top;
                            this.Controls[0].Controls.Add(cw);
                            this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].BringToFront();

                            // Reset for next batch
                            colorSpaceCount++;
                            alphaControl = null;
                            redControl = null;
                            greenControl = null;
                            blueControl = null;
                        }
                    }
                    else
                    {
                        colorSpaceCount++;
                    }

                    tabIndex++;
                }

            //ra.CloseReg();
        }
Exemplo n.º 40
0
        /// <summary>
        /// 根据指定的 tableName  和 DataValues 在 数据连接上执行插入操作
        /// </summary>
        /// <example>插入方法需要提供 要插入到的表名称 和 要插入的数据 DataValues 返回 大于0 表示成功</example>
        /// <param name="tableName">tableName</param>
        /// <param name="DataValues">DataValues</param>
        /// <returns>rows</returns>
        public virtual int Insert(string tableName, DataValues DataValues)
        {

            string sql = CreateInsertSQL(tableName, DataValues);
            return ExecSql(sql);
        }
Exemplo n.º 41
0
 /// <summary>
 /// CreateDeleteSQL
 /// </summary>
 /// <param name="tableName"></param>
 /// <param name="whereSql"></param>
 /// <param name="whereArgs"></param>
 /// <returns></returns>
 public string CreateDeleteSQL(string tableName, string whereSql, DataValues whereArgs)
 {
     StringBuilder stringBuilder = new StringBuilder("DELETE");
     stringBuilder.Append(" ");
     stringBuilder.Append("FROM");
     stringBuilder.Append(" ");
     stringBuilder.Append(tableName);
     stringBuilder.Append(" ");
     if (!String.IsNullOrEmpty(whereSql))
     {
         whereSql = CreateWhereSql(whereSql, whereArgs);
         stringBuilder.Append(" ");
         stringBuilder.Append(whereSql);
     }
     stringBuilder.Append(";");
     return stringBuilder.ToString();
 }
Exemplo n.º 42
0
            /// <summary>
            /// The button 1_ click.
            /// </summary>
            /// <param name="sender">The sender.</param>
            /// <param name="e">The e.</param>
            /// <remarks></remarks>
            private void button1_Click(object sender, EventArgs e)
            {
                ControlSwapper parent = (ControlSwapper)this.Parent.Parent.Parent;

                // Add selected control
                IFPIO.Option[] options = null;
                //int strLength = 0;
                Control con = null;
                switch (((dataTypeStruct)comboBox1.SelectedItem).name.ToLower())
                {
                    /*
                    parent.splitContainer1.Panel2.Controls.Add(new DataValues(parent.name, null, parent.chunkoffset, IFPIO.ObjectEnum.Byte, parent.lineNum));
                    parent.splitContainer1.Panel2.Controls.Add(new DataValues(parent.name, null, parent.chunkoffset, IFPIO.ObjectEnum.Short, parent.lineNum));
                    parent.splitContainer1.Panel2.Controls.Add(new DataValues(parent.name, null, parent.chunkoffset, IFPIO.ObjectEnum.Int, parent.lineNum));
                    parent.splitContainer1.Panel2.Controls.Add(new DataValues(parent.name, null, parent.chunkoffset, IFPIO.ObjectEnum.Float, parent.lineNum));
                */
                    case "byte":
                    case "short":
                    case "ushort":
                    case "int":
                    case "uint":
                    case "float":
                    case "unknown":
                    case "unused":
                        con = new DataValues(
                            parent.name,
                            null,
                            parent.chunkoffset,
                            (IFPIO.ObjectEnum)
                            Enum.Parse(typeof(IFPIO.ObjectEnum), ((dataTypeStruct)comboBox1.SelectedItem).name, true),
                            parent.lineNum);
                        break;
                    case "char_enum":
                    case "enum":
                    case "long_enum":
                        options = new IFPIO.Option[((dataTypeStruct)comboBox1.SelectedItem).size << 3];

                        // Size * 8 bits
                        for (int x = 0; x < options.Length; x++)
                        {
                            options[x] = new IFPIO.Option("Bit " + x, x.ToString(), parent.lineNum);
                        }

                        if (parent.splitContainer1.Panel1.Controls[0] is Bitmask)
                        {
                            Bitmask b = (Bitmask)parent.splitContainer1.Panel1.Controls[0];
                            foreach (IFPIO.Option o in b.Options)
                            {
                                if (o.value < options.Length)
                                {
                                    options[o.value].name = o.name;
                                }
                            }
                        }

                        ;
                        if (parent.splitContainer1.Panel1.Controls[0] is Enums)
                        {
                            Enums en = (Enums)parent.splitContainer1.Panel1.Controls[0];
                            foreach (IFPIO.Option o in en.Options)
                            {
                                if (o.value < options.Length)
                                {
                                    options[o.value].name = o.name;
                                }
                            }
                        }

                        ;
                        con = new Enums(parent.name, null, parent.chunkoffset, options.Length, options, parent.lineNum);
                        break;
                    case "byte_flags":
                    case "word_flags":
                    case "long_flags":
                        options = new IFPIO.Option[((dataTypeStruct)comboBox1.SelectedItem).size << 3];

                        // Size * 8 bits
                        for (int x = 0; x < options.Length; x++)
                        {
                            options[x] = new IFPIO.Option("Bit " + x, x.ToString(), parent.lineNum);
                        }

                        if (parent.splitContainer1.Panel1.Controls[0] is Bitmask)
                        {
                            Bitmask b = (Bitmask)parent.splitContainer1.Panel1.Controls[0];
                            foreach (IFPIO.Option o in b.Options)
                            {
                                options[o.value].name = o.name;
                            }
                        }

                        ;
                        if (parent.splitContainer1.Panel1.Controls[0] is Enums)
                        {
                            Enums en = (Enums)parent.splitContainer1.Panel1.Controls[0];
                            foreach (IFPIO.Option o in en.Options)
                            {
                                options[o.value].name = o.name;
                            }
                        }

                        ;
                        con = new Bitmask(
                            parent.name, null, parent.chunkoffset, options.Length, options, parent.lineNum);
                        break;
                    case "stringid":
                        con = new SID(parent.name, null, parent.chunkoffset, parent.lineNum);
                        break;
                    case "string":
                        con = new EntStrings(
                            parent.name,
                            null,
                            parent.chunkoffset,
                            ((dataTypeStruct)comboBox1.SelectedItem).size,
                            false,
                            parent.lineNum);
                        break;
                    case "unicodestring":
                        con = new EntStrings(
                            parent.name,
                            null,
                            parent.chunkoffset,
                            ((dataTypeStruct)comboBox1.SelectedItem).size,
                            true,
                            parent.lineNum);
                        break;
                    case "block":
                        con = new TagBlock(parent.name, null, parent.chunkoffset, parent.lineNum);
                        break;
                    case "ident":
                        con = new Ident(parent.name, null, parent.chunkoffset, true, parent.lineNum);
                        break;
                    case "struct":

                        // Unhandled
                        //int ifkdn = 0;
                        break;
                    default:
                        {
                            return;
                        }
                }

                Button but = new Button();
                but.Dock = DockStyle.Right;
                but.Size = new Size(30, 30);
                but.Text = "-";
                but.Click += but_Click;

                if (con != null)
                {
                    con.Controls.Add(but);

                    // con.Enabled = false;
                    con.Dock = DockStyle.Top;
                    Point loc = con.Controls[con.Controls.Count - 2].Location;
                    loc.X -= 50;
                    con.Controls[con.Controls.Count - 2].Location = loc;

                    // con.TabIndex--;
                    parent.splitContainer1.Panel2.Controls.Add(con);
                    con.BringToFront();
                    ((ControlSwapper)this.TopLevelControl).newControlSize +=
                        ((ControlSwapper)this.TopLevelControl).getSizeOf(((dataTypeStruct)comboBox1.SelectedItem).name);
                    if (((ControlSwapper)this.TopLevelControl).label1.Text.Contains(" :: "))
                    {
                        ((ControlSwapper)this.TopLevelControl).label1.Text =
                            ((ControlSwapper)this.TopLevelControl).label1.Text.Remove(
                                ((ControlSwapper)this.TopLevelControl).label1.Text.IndexOf(" :: "));
                    }

                    ((ControlSwapper)this.TopLevelControl).label1.Text += " :: New Control Size : " +
                                                                          ((ControlSwapper)this.TopLevelControl).
                                                                              newControlSize;
                }

                parent.splitContainer1.Panel2.Controls[parent.splitContainer1.Panel2.Controls.IndexOf(this)].
                    BringToFront();
                parent.splitContainer1.Panel2.Controls[parent.splitContainer1.Panel2.Controls.IndexOf(this)].TabIndex++;
            }
 public void AddToDataValues(DataValues dataValues)
 {
     base.AddObject("DataValues", dataValues);
 }
 public static DataValues CreateDataValues(int valueID, double dataValue, global::System.DateTime localDateTime, double uTCOffset, global::System.DateTime dateTimeUTC, int siteID, int variableID, string censorCode, int methodID, int sourceID, int qualityControlLevelID)
 {
     DataValues dataValues = new DataValues();
     dataValues.ValueID = valueID;
     dataValues.DataValue = dataValue;
     dataValues.LocalDateTime = localDateTime;
     dataValues.UTCOffset = uTCOffset;
     dataValues.DateTimeUTC = dateTimeUTC;
     dataValues.SiteID = siteID;
     dataValues.VariableID = variableID;
     dataValues.CensorCode = censorCode;
     dataValues.MethodID = methodID;
     dataValues.SourceID = sourceID;
     dataValues.QualityControlLevelID = qualityControlLevelID;
     return dataValues;
 }
Exemplo n.º 45
0
        /// <summary>
        /// CreateInsertSQL
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="contentValues"></param>
        /// <returns></returns>
        public string CreateInsertSQL(string tableName, DataValues contentValues)
        {
            StringBuilder stringBuilder = new StringBuilder("INSERT INTO");
            stringBuilder.Append(" ");
            if (String.IsNullOrEmpty(tableName))
            {
                throw new ArgumentException("tableName");
            }
            stringBuilder.AppendFormat("[{0}]", tableName);

            if (contentValues == null || contentValues.Count == 0)
            {
                throw new ArgumentException("contentValues");
            }
            string[] keys = contentValues.Keys;
            StringBuilder kBuilder = new StringBuilder();
            StringBuilder vBuilder = new StringBuilder();
            for (int i = 0; i < keys.Length; i++)
            {
                string key = keys[i];
                kBuilder.AppendFormat("[{0}]", key);
                vBuilder.AppendFormat("{0}", contentValues.Get(key));
                if ((i + 1) < keys.Length)
                {
                    kBuilder.Append(",");
                    vBuilder.Append(",");
                }
            }
            stringBuilder.AppendFormat("({0})", kBuilder);
            stringBuilder.AppendFormat("VALUES({0})", vBuilder);
            stringBuilder.Append(";");
            return stringBuilder.ToString();
        }
Exemplo n.º 46
0
 /// <summary>
 /// 根据指定的 <c>表名称</c> <c>列名称</c> <c>条件表达式</c> <c>条件参数</c>执行数据查询操作并返回一个数据指针
 /// </summary>
 /// <param name="tableName">表名称</param>
 /// <param name="columnNames">列名称</param>
 /// <param name="whereSql">条件表达式</param>
 /// <param name="whereArgs">条件参数</param>
 /// <summary>执行数据操作并</summary>
 /// <returns>返回一个数据指针</returns>
 public virtual Cursor Query(string tableName, string[] columnNames, string whereSql, DataValues whereArgs)
 {
     string sql = CreateSelectSQL(tableName, columnNames, whereSql, whereArgs);
     return Query(sql);
 }
Exemplo n.º 47
0
 /// <summary>
 /// 根据指定的 tableName,whereSql  和 whereArgs  在 数据连接上执行删除操作
 /// </summary>
 /// <param name="tableName"></param>
 /// <param name="whereSql"></param>
 /// <param name="whereArgs"></param>
 /// <returns></returns>
 public virtual int Delete(string tableName, string whereSql, DataValues whereArgs)
 {
     string sql = CreateDeleteSQL(tableName,whereSql,whereArgs);
     return ExecSql(sql);
 }
Exemplo n.º 48
0
 /// <summary>
 /// CreateUpdateSQL
 /// </summary>
 /// <param name="tableName"></param>
 /// <param name="values"></param>
 /// <param name="whereSql"></param>
 /// <param name="whereArgs"></param>
 /// <returns></returns>
 public string CreateUpdateSQL(string tableName, DataValues values, string whereSql, DataValues whereArgs)
 {
     StringBuilder stringBuilder = new StringBuilder("UPDATE");
     stringBuilder.Append(" ");
     stringBuilder.AppendFormat("[{0}]", tableName);
     string[] keys = values.Keys;
     if (keys == null || keys.Length == 0)
     {
         throw new ArgumentException("values");
     }
     stringBuilder.Append(" ");
     stringBuilder.Append("SET");
     stringBuilder.Append(" ");
     for (int i = 0; i < values.Count; i++)
     {
         string key = keys[i];
         stringBuilder.AppendFormat("[{0}] = {1}", key, values.Get(key));
         if ((i + 1) < keys.Length)
         {
             stringBuilder.Append(",");
         }
     }
     if (!String.IsNullOrEmpty(whereSql))
     {
         whereSql = CreateWhereSql(whereSql, whereArgs);
         stringBuilder.Append(" ");
         stringBuilder.Append(whereSql);
     }
     stringBuilder.Append(";");
     return stringBuilder.ToString();
 }