Example #1
1
        public ConditionResolver(IList<Condition> conditions)
        {
            if (conditions.IsNullOrEmpty())
                throw new ArgumentNullException(nameof(conditions));

            _conditions = conditions;
        }
		/// <summary>
		/// Serializes the list of active plugins to the permanent store.
		/// </summary>
		/// <returns>The ordered list of active plugins.</returns>
		public void SavePluginLog(IList<Plugin> p_lstActivePlugins)
		{
			if (p_lstActivePlugins.IsNullOrEmpty())
			{
				LoadOrderManager.SetActivePlugins(GameMode.OrderedCriticalPluginNames);
				return;
			}
			
			List<string> lstPlugins = new List<string>();
			foreach (Plugin plgPlugin in p_lstActivePlugins)
				lstPlugins.Add(plgPlugin.Filename);
			lstPlugins.Sort();

			List<string> lstActivePlugins = new List<string>();
			foreach (string strPlugin in GameMode.OrderedCriticalPluginNames)
			{
				lstPlugins.RemoveAll(x => x.Equals(strPlugin, StringComparison.CurrentCultureIgnoreCase));
				if (!lstActivePlugins.Contains(strPlugin, StringComparer.CurrentCultureIgnoreCase))
					lstActivePlugins.Add(strPlugin);
			}
			foreach (Plugin plgPlugin in PluginOrderLog.OrderedPlugins)
			{
				if (lstPlugins.Contains(plgPlugin.Filename, StringComparer.CurrentCultureIgnoreCase))
					if (!lstActivePlugins.Contains(plgPlugin.Filename, StringComparer.CurrentCultureIgnoreCase))
						lstActivePlugins.Add(plgPlugin.Filename);
			}
			LoadOrderManager.SetActivePlugins(lstActivePlugins.ToArray());
		}
        public List<EHistoryDataStoreConfig> GetVehicleStoreTableConfigList(IList<Guid> vehicleCodes)
        {
            if (vehicleCodes.IsNullOrEmpty())
                return null;

            List<EHistoryDataStoreConfig> res = null;
            string cmdText = string.Format("select RecordID, VehicleCode, StoreTable, ENABLE, CreateDate, remark from gps_historydatastoreconfig where VehicleCode in ('{0}')", vehicleCodes.JoinToString<Guid>("','"));
            using (MySqlDataReader sdr = MySqlDB.GetDataReader(CommandType.Text, cmdText))
            {
                if (sdr != null)
                {
                    res = new List<EHistoryDataStoreConfig>();
                    while (sdr.Read())
                    {
                        res.Add(new EHistoryDataStoreConfig
                        {
                            RecordID = sdr.GetGuid(0),
                            VehicleCode = sdr.GetGuid(1),
                            StoreTable = GetHisotryDataStoreTable(sdr.GetGuid(2)),
                            Enable = sdr.GetShort(3) == 1,
                            CreateDate = sdr.GetDateTimeExt(4),
                            Remark = sdr.GetStringExt(5)
                        });
                    }
                    sdr.Close();
                }
            }
            return res;
        }
Example #4
1
        /// <summary>
        /// 统计停车次数,过滤停车时长小于指定值的次数
        /// </summary>
        /// <param name="ltVehicleCode"></param>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <param name="second"></param>
        /// <param name="tenantCode"></param>
        /// <returns></returns>
        public Dictionary<Guid, VCountStopCar> Count(IList<Guid> ltVehicleCode, DateTime beginTime, DateTime endTime, int second, string tenantCode)
        {
            if (ltVehicleCode.IsNullOrEmpty())
                return new Dictionary<Guid, VCountStopCar>();

            Dictionary<Guid, TimeSpan> totalTimes; //运行轨迹的总时长
            IList<VStopCarReport> list = SearchStop(ltVehicleCode, beginTime, endTime, second, tenantCode, out totalTimes);
            
            Dictionary<Guid, VCountStopCar> dic = new Dictionary<Guid, VCountStopCar>();
            if (list != null && list.Count > 0)
            { //合并停车明细
                VCountStopCar vCount;
                foreach (var item in list)
                {
                    if (dic.ContainsKey(item.VehicleCode))
                    {
                        vCount = dic[item.VehicleCode];
                        vCount.Count++;
                        vCount.CountTime += item.StopTimeSpan;
                        //vCount.TotalTime += item.TotalTimeSpan;
                    }
                    else
                    {
                        vCount = new VCountStopCar();
                        vCount.Count++;
                        vCount.CountTime = item.StopTimeSpan;
                        //vCount.TotalTime = item.TotalTimeSpan;
                        vCount.VehicleCode = item.VehicleCode;
                        vCount.LicenceNumber = item.LicenceNumber;
                        dic.Add(vCount.VehicleCode, vCount);
                    }
                }
            }
            foreach (var item in totalTimes)
            {
                if (dic.ContainsKey(item.Key))
                {
                    dic[item.Key].TotalTime = item.Value;
                }
                else
                {
                    dic.Add(item.Key, new VCountStopCar
                    {
                        VehicleCode = item.Key,
                        Count = 0,
                        CountTime = new TimeSpan(0),
                        TotalTime = item.Value
                    });
                }
            }

            return dic;
        }
        public void Delete(IList<Guid> vehicleCodes, Guid areaCode)
        {
            if (vehicleCodes.IsNullOrEmpty())
                return;
            using (IRepository repository = SessionManager.CreateRepository(typeof(ETraceAlertSetting)))
            {
                Query query = new Query(typeof(ETraceAlertSetting));
                Expression expression = null;
                ExpressionUtility<Guid>.AddExpression("VehicleCode", vehicleCodes, PolynaryOperatorType.In, ref expression);
                ExpressionUtility<Guid>.AddExpression("TracePoint.RecordID", areaCode, BinaryOperatorType.EqualTo, ref expression);

                query.Expression = expression;
                repository.DeleteBy(query);
            }
        }
        public Grid Build(IList<IPanelItem> items)
        {
            var grid = new Grid();

            var i = 1;

            while (!items.IsNullOrEmpty())
            {
                grid.Blocks.Add(GenerateBlock(items.Take(i)));

                items = items.Skip(i).ToList();

                if (items.IsNullOrEmpty())
                    break;

                i = i == 1 ? 4 : 1;

                grid.Blocks.Add(GenerateBlock(items.Take(i)));

                items = items.Skip(i).ToList();
            }

            return grid;
        }
 private static IList<ParameterInstances> Expand(IList<ParameterInstances> instancesList, IList<ParameterDefinition> definitions)
 {
     if (definitions.IsNullOrEmpty())
         return instancesList;
     var nextDefinition = definitions.First();
     var newInstancesList = new List<ParameterInstances>();
     foreach (var instances in instancesList)
         foreach (var value in nextDefinition.Values)
         {
             var items = new List<ParameterInstance>();
             items.AddRange(instances.Items);
             items.Add(new ParameterInstance(nextDefinition, value));
             newInstancesList.Add(new ParameterInstances(items));
         }
     return Expand(newInstancesList, definitions.Skip(1).ToArray());
 }
        public IList<EBreakOilLastRecord> Search(IList<Guid> vehicleCodes)
        {
            if (vehicleCodes.IsNullOrEmpty())
            {
                return null;
            }
            using (IRepository repository = SessionManager.CreateRepository(typeof(EBreakOilLastRecord)))
            {
                Query query = new Query(typeof(EBreakOilLastRecord));
                Expression expression = Expression.CreateExpression("VehicleCode", PolynaryOperatorType.In, vehicleCodes);
                query.Expression = expression;
        
                var list = repository.List<EBreakOilLastRecord>(query);

                return list;
            }
        }
        public IAsyncOperation<IList<SynchronizedType>> GetMultipleAsync(IList<string> typeIDs)
        {
            if (typeIDs.IsNullOrEmpty())
            {
                throw new ArgumentException("typeIDs");
            }

            return AsyncInfo.Run<IList<SynchronizedType>>(async cancelToken =>
            {
                List<SynchronizedType> sTypes = new List<SynchronizedType>();
                foreach(string typeID in typeIDs)
                {
                    SynchronizedType type = await this.Ensure(typeID, cancelToken);
                    sTypes.Add(type);
                }

                return sTypes;
            });
        }
Example #10
1
        static bool Target(IList<string> unparsed)
        {
            string url = command_url;
            if (false == unparsed.IsNullOrEmpty())
            {
                url = unparsed[0];
            }

            IVcapClient vc = new VcapClient();
            VcapClientResult rslt = vc.Target(url);
            if (rslt.Success)
            {
                Console.WriteLine(String.Format(Resources.Vmc_TargetDisplay_Fmt, rslt.Message));
            }
            else
            {
                Console.WriteLine(String.Format(Resources.Vmc_TargetNoSuccessDisplay_Fmt, rslt.Message));
            }

            return rslt.Success;
        }
        public IAsyncOperation<IList<SynchronizedView>> GetViewsAsync(IList<string> viewNames)
        {
            if (viewNames.IsNullOrEmpty())
            {
                throw new ArgumentException("viewNames");
            }

            return AsyncInfo.Run<IList<SynchronizedView>>(async cancelToken => 
            {
                LazyList<SynchronizedView> views = new LazyList<SynchronizedView>();
                foreach(string viewName in viewNames)
                {
                    SynchronizedView view = await this.GetViewAsync(viewName, cancelToken);
                    if (view != null)
                    {
                        views.Add(view);
                    }
                }

                return views.HasValue ? views.Value : null;
            });
        }
Example #12
1
        public async Task SaveLocalItems(IList<ReaderItem> items)
        {
            await WriteItemsToDisk(items, SourceProvider.Local);

            if (!items.IsNullOrEmpty())
            {
                CacheCount.LocalCount = items.Count;
            }
            else
            {
                CacheCount.LocalCount = null;
            }

            WriteCountsToStorage().ConfigureAwait(false);
        }
        public IAsyncOperation<IList<RecordItemChange>> GetChangesForItemsAsync(IList<string> itemIDs)
        {
            if (itemIDs.IsNullOrEmpty())
            {
                throw new ArgumentException("itemID");
            }

            return AsyncInfo.Run<IList<RecordItemChange>>(async cancelToken =>
            {
                using (await CrossThreadLockScope.Enter(m_lock))
                {
                    List<RecordItemChange> changes = new List<RecordItemChange>();
                    foreach(string id in itemIDs)
                    {
                        RecordItemChange change = await this.GetChangeAsync(id);
                        if (change != null)
                        {
                            changes.Add(change);
                        }
                    }
                    return changes;
                }
            });
        }
Example #14
0
        public IList<EGPSCurrentInfo> GetCurrentInfoList(IList<Guid> ltVehicleCode)
        {   
            //Query query = new Query(typeof(EGPSCurrentInfo));
            //query.Expression = Expression.CreateExpression("VehicleCode", PolynaryOperatorType.In, ltVehicleCode);
            //using (IRepository repository = SessionManager.CreateRepository(typeof(EGPSCurrentInfo)))
            //{
            //    return repository.List<EGPSCurrentInfo>(query);
            //}

            //优化
            if (ltVehicleCode.IsNullOrEmpty())
                return null;

            List<EGPSCurrentInfo> list = null;
            string sqlText = string.Format(@"SELECT ID,GPSCode,Longitude,Latitude,Speed,Direction,ReportTime,OilState,ACCState,Mileage,PowerState,
StarkMileage,AntennaState,OilBearing,DoorStatus,PhotoPath,VehicleCode,PlunderState,Detector1,Detector2,Detector3,Detector4,CoolerStatus
 FROM gps_currentinfo WHERE VehicleCode in ('{0}')", ltVehicleCode.JoinToString<Guid>("','"));

            using (MySqlDataReader sdr = MySqlDB.GetDataReader(CommandType.Text, sqlText))
            {
                if (sdr != null)
                {
                    list = new List<EGPSCurrentInfo>();
                    while (sdr.Read())
                    {
                        list.Add(new EGPSCurrentInfo
                        {
                            ID = sdr.GetGuid(0),
                            GPSCode = sdr.GetString(1),
                            Longitude = sdr.GetDouble(2),
                            Latitude = sdr.GetDouble(3),
                            Speed = sdr.GetDouble(4),
                            Direction = sdr.GetDouble(5),
                            ReportTime = sdr.GetDateTime(6),
                            OilState = sdr.GetInt(7),
                            ACCState = sdr.GetInt(8),
                            Mileage = sdr.GetDouble(9),
                            PowerState = sdr.GetInt(10),
                            StarkMileage = sdr.GetDouble(11),
                            AntennaState = sdr.GetInt(12),
                            OilBearing = sdr.GetDoubleExt(13),
                            DoorStatus = sdr.GetInt(14),
                            PhotoPath = sdr.GetStringExt(15),
                            VehicleCode = sdr.GetGuidExt(16),
                            PlunderState = sdr.GetInt16(17),
                            Detector1 = sdr.GetFloatNull(18),
                            Detector2 = sdr.GetFloatNull(19),
                            Detector3 = sdr.GetFloatNull(20),
                            Detector4 = sdr.GetFloatNull(21),
                            CoolerStatus = sdr.GetInt(22)
                        });
                    }
                    sdr.Close();
                }
            }

            return list;
        }
        /// <summary>
        /// Synchronize multiple types with a single roundtrip
        /// </summary>
        /// <param name="typeIDs">TypeIds to sync</param>
        /// <param name="maxAgeInSeconds">View age</param>
        /// <returns>A list of type ids actually synchronized</returns>
        public IAsyncOperation<IList<string>> SynchronizeTypesAsync(IList<string> typeIDs, int maxAgeInSeconds)
        {
            if (typeIDs.IsNullOrEmpty())
            {
                throw new ArgumentException("typeIDs");
            }
            if (maxAgeInSeconds < 0)
            {
                throw new ArgumentException("maxAgeInSeconds");
            }

            return AsyncInfo.Run<IList<string>>(async cancelToken =>
            {
                IList<SynchronizedType> sTypes = await this.GetMultipleAsync(typeIDs);
                SynchronizedViewSynchronizer synchronizer = new SynchronizedViewSynchronizer(m_recordStore.Record, maxAgeInSeconds);
                synchronizer.MaxAgeInSeconds = maxAgeInSeconds;

                IList<ISynchronizedView> synchronized = await synchronizer.SynchronizeAsync(sTypes.Cast<ISynchronizedView>().ToList());
                if (synchronized.IsNullOrEmpty())
                {
                    return null;
                }
                
                string[] syncedIDs = (from view in synchronized
                        select ((SynchronizedType) view).TypeID).ToArray();

                return syncedIDs;
            });
        }
Example #16
0
 public LoggingInfo(IList list)
 {
     if (list.IsNullOrEmpty()) return;
     Levels = list.Cast<string>().ToList();
 }
Example #17
0
        static bool Login(IList<string> unparsed)
        {
            bool failed = true;
            ushort tries = 0;

            while (failed && tries < 3)
            {
                string email = command_email;
                if (false == unparsed.IsNullOrEmpty())
                {
                    email = unparsed[0];
                }
                if (prompt_ok && email.IsNullOrWhiteSpace())
                {
                    Console.Write(Resources.Vmc_EmailPrompt_Text);
                    email = Console.ReadLine();
                }

                string password = command_password;
                if (prompt_ok && password.IsNullOrWhiteSpace())
                {
                    Console.Write(Resources.Vmc_PasswordPrompt_Text);
                    password = readPassword();
                }

                Console.WriteLine();

                if (email.IsNullOrWhiteSpace())
                {
                    Console.Error.WriteLine(Resources.Vmc_NeedEmailPrompt_Text);
                    return false;
                }

                if (password.IsNullOrWhiteSpace())
                {
                    Console.Error.WriteLine(Resources.Vmc_NeedPasswordPrompt_Text);
                    return false;
                }

                IVcapClient vc = new VcapClient();
                try
                {
                    VcapClientResult rslt = vc.Login(email, password);
                    if (rslt.Success)
                    {
                        Console.WriteLine(String.Format(Resources.Vmc_LoginSuccess_Fmt, vc.CurrentUri));
                        failed = false;
                    }
                    else
                    {
                        Console.Error.WriteLine(String.Format(Resources.Vmc_LoginFail_Fmt, vc.CurrentUri));
                    }
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine(String.Format(Resources.Vmc_LoginError_Fmt, vc.CurrentUri, e.Message));
                }

                ++tries;
            }

            return false == failed;
        }
Example #18
0
        /// <summary>
        /// The get kpi gadget data.
        /// </summary>
        /// <param name="processName">
        /// The process name.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <returns>
        /// The <see cref="IList"/>.
        /// </returns>
        public IList<KpiItem> GetKpiGadgetData(string processName, IList<KpiParameters> parameters)
        {
            if (string.IsNullOrWhiteSpace(processName)) return null;
            if (parameters.IsNullOrEmpty()) return null;
            _selectedKPIList.Clear();
            if (parameters != null)
            {
                foreach (var parameter in parameters)
                {
                    var random = Guid.NewGuid();
                    var kpiinfo = this.DynamicTypeManager.GetGadgetAggregateInfo(processName, parameter.KpiGuid, random);

                    if (!IconList.Any())
                    {
                        var items = this.DynamicTypeManager.GetInfoList<IIcon>(Constants.IconProcessName, string.Empty, 0, int.MaxValue);
                        if (items != null)
                            IconList.AddRange(items);
                    }

                    var icon = IconList.FirstOrDefault(x => x.Id == kpiinfo.CurrentIconID);
                    var iconName = icon != null ? icon.name : kpiinfo.CurrentIconURL;

                    this._selectedKPIList.Add(new KpiItem(kpiinfo.Id, kpiinfo.Name, kpiinfo.Guid, kpiinfo.CurrentValue, iconName));
                }
            }

            return _selectedKPIList;
        }
Example #19
0
 protected void WriteArray(JsonWriter writer, IList list)
 {
     writer.WriteStartArray();
     if (list.IsNullOrEmpty())
     {
         writer.WriteEndArray();
         return;
     }
     for (int i = 0; i < list.Count; i++)
     {
         var value = list[i];
         if (value is INamedList)
             WriteNamedList(writer, value as INamedList);
         else if (value is IList)
             WriteArray(writer, value as IList);
         else
             writer.WriteValue(value);
     }
     writer.WriteEndArray();
 }
        async Task UpdateViews(IList<ISynchronizedView> views, IList<ItemQueryResult> queryResults)
        {
            int iResult = 0;
            for (int i = 0, count = views.Count; i < count; ++i)
            {
                ItemQuery query = m_syncQueries[i];
                if (query != null)
                {
                    ItemQueryResult queryResult = null;
                    if (!queryResults.IsNullOrEmpty())
                    {
                        queryResult = queryResults[iResult++];
                    }

                    await this.UpdateKeys(views[i], queryResult);
                }                
            }
        }
        /// <summary>
        /// Adds the metric current metric read data.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="metric">The metric.</param>
        /// <param name="groupingFieldsList">The grouping fields list.</param>
        /// <returns>System.String.</returns>
        private static string AddMetricCurrentMetricReadData(IProcessDefinition process, IMetricDefinition metric, IList<string> groupingFieldsList)
        {
            string readDataFirstInfoObject = null;
            var columnType = GetMetricOrderByFieldType(process, metric, groupingFieldsList);

            Action getReadDataFirstInfoObject = () =>
            {
                if (columnType.HasValue && (columnType.Value == ColumnTypes.Approval || columnType.Value == ColumnTypes.Boolean))
                {
                    readDataFirstInfoObject = "item.Value.First()";
                    return;
                }

                if (!groupingFieldsList.Any())
                {
                    return;
                }

                if (metric.MetricFieldSystemName == metric.OrderByMetricField || (metric.SummaryType == SummaryTypes.Count && metric.OrderByMetricField == string.Empty))
                {
                    readDataFirstInfoObject = "item.Key";
                    return;
                }

                if (!string.IsNullOrWhiteSpace(metric.OrderByMetricField))
                {
                    readDataFirstInfoObject = "item.Source.First()";
                    return;
                }

                readDataFirstInfoObject = "item.ToList().First()";
            };

            getReadDataFirstInfoObject();

            string metricinfoClass;

            if (columnType.HasValue && (columnType.Value == ColumnTypes.Approval || columnType.Value == ColumnTypes.Boolean))
            {
                metricinfoClass = "Value.First()";
            }
            else
                if (!string.IsNullOrWhiteSpace(metric.OrderByMetricField) && metric.MetricFieldSystemName != metric.OrderByMetricField)
                {
                    metricinfoClass = "Source.First()";
                }
                else
                {
                    metricinfoClass = "Key";
                }

            var groupByFieldValuesList = new List<string>();

            foreach (var groupedField in groupingFieldsList)
            {
                var field = GetField(process, groupedField);
                var groupFieldPath = groupedField;
                if (!string.IsNullOrWhiteSpace(metric.OrderByMetricField) && metric.MetricFieldSystemName != metric.OrderByMetricField)
                {
                    groupFieldPath = field.Key;
                }

                if (groupedField == field.Value.SystemName)
                {
                    var variable = string.Format("var {0}_value = ", groupedField);

                    switch (field.Value.ColumnType)
                    {
                        case ColumnTypes.DateTime:
                            variable += string.Format(@"dtConverter.Convert({0}.{1}, null, ""{2}"", null);"
                                                      , readDataFirstInfoObject
                                                      , field.Key
                                                      , field.Value.DateTimeFormat);
                            break;
                        case ColumnTypes.Approval:
                            if (metric.OrderByMetricField == field.Value.SystemName)
                            {
                                variable += "item.Key;";
                            }
                            else
                            {
                                variable += string.Format(@"approvalConvertMethod.Invoke(approvalInstance, new object[] {{ item.{0}.{1}, null, null, null }});", metricinfoClass, groupFieldPath);
                            }
                            break;
                        case ColumnTypes.Boolean:
                            var result = field.Value.NameValuesList["IsSwitchToggle"];
                            if (Convert.ToBoolean(result))
                            {
                                if (metric.OrderByMetricField == field.Value.SystemName)
                                {
                                    variable += "item.Key;";
                                }
                                else
                                {
                                    var converterParameter = string.Format("{0}~{1}~{2}",
                                  ((string)field.Value.NameValuesList["UndefinedLabel"]).Replace("\"", null),
                                  ((string)field.Value.NameValuesList["FalseLabel"]).Replace("\"", null),
                                  ((string)field.Value.NameValuesList["TrueLabel"]).Replace("\"", null))
                          .ToLiteral();
                                    variable += string.Format(@"boolConverter.Convert(item.{0}.{1}, null, {2}, CultureInfo.InvariantCulture);", metricinfoClass, groupFieldPath, converterParameter);
                                }
                            }
                            else
                            {
                                goto default;
                            }
                            break;

                        default:
                            variable += string.Format("item.{0}.{1};", metricinfoClass, groupFieldPath);
                            break;
                    }

                    variable += Environment.NewLine;

                    groupByFieldValuesList.Add(variable);
                }
            }



            return string.Format(@"
                var currentMetric = new {0}Metric_{1}();

                {2}

                currentMetric.ReadData(Convert.ToDecimal({3}) {4}{5});

                Add(currentMetric);"
                    , process.Name
                    , metric.Guid.ToString().Replace("-", string.Empty)
                    , string.Join(string.Empty, groupByFieldValuesList)
                    , metric.MetricFieldSystemName == metric.OrderByMetricField || readDataFirstInfoObject == "item.Key" ? "item.Value" : "result"
                    , readDataFirstInfoObject != null ? ", " + readDataFirstInfoObject : null
                    , groupingFieldsList.IsNullOrEmpty() ? null : ", " + string.Join(",", groupingFieldsList.Select(f => string.Format("{0}_value", f))));
        }
        internal ItemQuery CreateRefreshQueryForKeys(IList<ItemKey> keys, IList<string> typeVersions)
        {
            ItemQuery query = ItemQuery.QueryForKeys(keys);
            query.View.SetSections(SectionsToFetch);
            if (!typeVersions.IsNullOrEmpty())
            {
                query.View.TypeVersions.AddRange(typeVersions);
            }

            return query;
        }
Example #23
0
        public async Task<IResult> DeleteCustomFieldsAsync(IList<CustomField> customFields)
        {
            IResult result = null;

            if (customFields.IsNullOrEmpty())
            {
                result = new ShopTimeResult()
                {
                    Error = new Error() { Message = "customFields can't be null or empty."}
                };
            }

            try
            {
                foreach (var customField in customFields)
                {
                    customField.IsDeleted = true;
                }

                await _customFieldRepo.UpdateAsync(customFields)
                    .Error(err =>
                    {
                        result = new ShopTimeResult() { Error = err};
                    })
                    .Success(() =>
                    {
                        result = new ShopTimeResult();
                    });

            }
            catch (Exception ex)
            {
                result = new ShopTimeResult()
                {
                    Error = new Error() { CodeNumber = 500, Message = ex.Message }
                };
            }

            return result;
        }
        public IAsyncAction PutViewsAsync(IList<SynchronizedView> views)
        {
            if (views.IsNullOrEmpty())
            {
                throw new ArgumentException("views");
            }

            return AsyncInfo.Run(async cancelToken => 
            {
                foreach(SynchronizedView view in views)
                {
                    view.ValidateRequired("view");
                    await this.PutViewAsync(view, cancelToken);
                }
            });
        }
Example #25
0
        private void PrepareGroups(IList<string> groupsNames)
        {
            var groupsDict = CreateProperties()
                .GroupBy(x => x.GroupName)
                .ToDictionary(x => x.Key);

            Groups = new List<GroupProperties>();
            if (groupsNames.IsNullOrEmpty())
            {
                foreach (var group in groupsDict)
                {
                    Groups.Add(new GroupProperties
                    {
                        GroupName = group.Key,
                        Properties = group.Value.ToList()
                    });
                }
            }
            else
            {
                foreach (var groupName in groupsNames)
                {
                    var trimedGroupName = groupName.TrimEnd('*');
                    if (!groupsDict.ContainsKey(trimedGroupName)) continue;

                    var group = groupsDict[trimedGroupName];

                    Groups.Add(new GroupProperties
                    {
                        GroupName = @group.Key,
                        Properties = @group.ToList(),
                        IsCollapsed = groupName.EndsWith("*")
                    });
                }
            }
        }
Example #26
0
        private Dictionary<EHisotryDataStoreTables, IList<Guid>> GroupByStoreTable(
            IList<EHistoryDataStoreConfig> ltTableConfig)
        {
            if (ltTableConfig.IsNullOrEmpty())
            {
                return null;
            }

            Dictionary<EHisotryDataStoreTables, IList<Guid>> dic = new Dictionary<EHisotryDataStoreTables, IList<Guid>>();            
            IList<Guid> ltVehicleCode;
            foreach (var item in ltTableConfig)
            {
                if (dic.ContainsKey(item.StoreTable))
                {
                    ltVehicleCode = dic[item.StoreTable];
                }
                else
                {
                    ltVehicleCode = new List<Guid>();
                    dic.Add(item.StoreTable, ltVehicleCode);
                }
                ltVehicleCode.Add(item.VehicleCode);
            }
            return dic;
        }
Example #27
0
        private bool CheckCommandCondition(IList<EGPSCurrentInfo> ltCurrent, CommandResultViewModel vm,
            EnumOilCommandType commandType)
        {
            if (ltCurrent.IsNullOrEmpty())
            {
                vm.Msg = "车辆已经离线,无法操作";
                vm.CommandResult = EnumCommandResult.MisMatchCondition;
                return false;
            }
            TimeSpan timeSpan = DateTime.Now.Subtract(ltCurrent[0].ReportTime);
            if (timeSpan.TotalMinutes > Param_OffLineTime)
            {
                vm.Msg = "车辆已经离线,无法操作";
                vm.CommandResult = EnumCommandResult.MisMatchCondition;
                return false;
            }
            if (commandType == EnumOilCommandType.BreakOil)
            {
                if (ltCurrent[0].OilState != 1)          //1 表示油电路正常
                {
                    vm.Msg = "车辆油电路已经断开";
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    return false;
                }
                if (ltCurrent[0].Speed >= 30)
                {
                    vm.Msg = "此操作在速度30公里/时才能操作";
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    return false;
                }
            }
            else if (commandType == EnumOilCommandType.Support)
            {
                if (ltCurrent[0].OilState == 1)          //1 表示油电路正常
                {
                    vm.Msg = "车辆油电路已正常";
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    return false;
                }
            }

            return true;
        }
Example #28
0
 /// <summary>
 /// 获取所有准确历史数据时只获取IsGPSOverFlow=0;
 /// </summary>
 private IList<EGPSHistoryInfo> GetGPSHistoryInfoList(EHisotryDataStoreTables table , IList<Guid> ltVehicleCode, DateTime beginTime, DateTime endTime)
 {
     if (table == null || ltVehicleCode.IsNullOrEmpty())
         return null;
     string codes = string.Join("','", ltVehicleCode.Select(s => s.ToString()).ToArray());
     codes = " ('" + codes + "') ";
     string sqlText = string.Format("select * from {0} where VehicleCode in {1} and reporttime between '{2}' and '{3}' and IsGPSOverFlow=0  order by ReportTime asc ",
         table.TableName, codes, beginTime, endTime);
     return List(table.SelectConnStr, sqlText);
 }
        /// <summary>
        /// Receives messages from source queue and puts them into destination queues.
        /// </summary>
        /// <param name="sourceQueue"></param>
        /// <param name="inboundMessages"></param>
        private void RelayMessagesInternal(CloudQueue sourceQueue, IList<CloudQueueMessage> inboundMessages)
        {
            if (inboundMessages.IsNullOrEmpty())
                return;

            if (this.DestinationQueues.IsNullOrEmpty())
                throw new Exception("Cannot relay queue messages because destination queue(s) are not specified.");

            this.LogInformation("Received {0} messages from queue \"{1}\". Dispatching them to {2} destination queues.", inboundMessages.Count, sourceQueue.Name, this.DestinationQueues.Count);
            //messages.ForEach(msg => this.LogInformation("Received message at {0}:\r\n\"{1}\"\r\n", DateTimeOffset.Now, msg.AsString));

            var stopWatch = new Stopwatch();
            stopWatch.Start();

            inboundMessages = this.TransformInboundMessages(inboundMessages, stopWatch);

            this.ForwardMessages(inboundMessages.Count, inboundMessages, stopWatch);

            this.DeleteSourceMessages(sourceQueue, inboundMessages, stopWatch);
        }
Example #30
0
 /// <summary>
 /// Constructs a new course for this fleet from the <c>vectorCourse</c> provided.
 /// </summary>
 /// <param name="vectorCourse">The vector course.</param>
 private void ConstructApCourse(IList<Vector3> vectorCourse) {
     if (vectorCourse.IsNullOrEmpty()) {
         D.Error("{0}'s vectorCourse contains no course to {1}.", DebugName, ApTarget.DebugName);
         return;
     }
     ApCourse.Clear();
     int destinationIndex = vectorCourse.Count - 1;  // no point adding StationaryLocation for Destination as it gets immediately replaced
     for (int i = 0; i < destinationIndex; i++) {
         ApCourse.Add(new StationaryLocation(vectorCourse[i]));
     }
     ApCourse.Add(ApTarget); // places it at course[destinationIndex]
     HandleApCourseChanged();
 }