private DotNet.Highcharts.Highcharts GetChart(Series[] series, DataEnum data)
        {
            Chart chart = null;
            XAxis xAxis = null;
            PlotOptions options = null;
            switch (data)
            {
                case DataEnum.random_points:
                    xAxis = new XAxis { Categories = new[] { "50", "100", "500", "1k", "5k", "10k", "50k", "100k", "500k", "1M", "2M", "3M", "4M", "5M" } };
                    options = new PlotOptions();
                    chart = new Chart();
                    break;
                case DataEnum.countries:
                    xAxis = new XAxis { Categories = series.Select(t => t.Name).ToArray() };
                    options = new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } };
                    chart = new Chart { DefaultSeriesType = ChartTypes.Column };

                    // ReSharper disable once PossibleNullReferenceException
                    var results = new object[series.Length];
                    for (int i = 0; i < series.Length; i++)
                        results[i] = series.FirstOrDefault(x => x.Name.Equals(series[i].Name)).Data.ArrayData[0];
                    series = new[]{ new Series{ Name = data.ToString(), Data = new Data(results)} };

                    break;
            }

            return new DotNet.Highcharts.Highcharts("chart")
                .InitChart(chart)
                .SetTitle(new Title{ Text = "Comparison result" })
                .SetXAxis(xAxis)
                .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Time (ms)" }, })
                .SetSeries(series)
                .SetPlotOptions(options);
        }
        public void EnableIndex(IndexEnum index, DataSizeEnum dataSize, DataEnum data)
        {
            string indexName = data.ToString();

            indexName += (dataSize == DataSizeEnum.None ? string.Empty : "_" + (int)dataSize);
            indexName += "_" + index + @"_idx";

            if (data == DataEnum.countries)
            {
                if (index == IndexEnum.gist)
                {
                    indexName = "countries_geom_gist";
                }
                else
                {
                    return;
                }
            }

            string dropIndexCommandText = @"UPDATE pg_index SET indislive = true, indisvalid = true where indexrelid = '" + indexName + @"'::regclass;";
            int    rowsChanged;

            using (var command = new NpgsqlCommand(dropIndexCommandText, _conn))
                rowsChanged = command.ExecuteNonQuery();
            if (rowsChanged != 1)
            {
                throw new Exception("Nieudana kwerenda - " + dropIndexCommandText);
            }
        }
        public void CreateIndex(IndexEnum index, DataSizeEnum dataSize, DataEnum data)
        {
            string indexName = data.ToString();
            indexName += (dataSize == DataSizeEnum.None ? string.Empty : "_" + (int)dataSize);
            indexName += "_" + index + @"_idx";

            if (data == DataEnum.countries)
            {
                if (index == IndexEnum.gist)
                    indexName = "countries_geom_gist";
                else return;
            }

            string createIndexCommandText =
                @"DO $$
                BEGIN
                IF NOT EXISTS (
                    SELECT 1
                    FROM   pg_class c
                    JOIN   pg_namespace n ON n.oid = c.relnamespace
                    WHERE  c.relname = '" + indexName + @"'
                    AND    n.nspname = 'public'
                    ) THEN
                    CREATE INDEX " + indexName + @"
                    ON random_points_" + (int)dataSize + @"
                    USING " + index + @" (geom);
                END IF;
                END$$;";

            using (var command = new NpgsqlCommand(createIndexCommandText, _conn))
                command.ExecuteNonQuery();
        }
Пример #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="day"></param>
        /// <param name="channelID"></param>
        /// <returns></returns>
        public static DataTable GetDayDataTable( DateTime begin, DateTime end, string[] stationNames, DataEnum de)
        {
            string s = MakeSql(begin, end, stationNames,de);

            DataTable tbl = DBI.GetDBI().ExecuteDataTable(s);
            return tbl;
        }
Пример #5
0
        private void CfPExecute_Load(object sender, EventArgs e)
        {
            try
            {
                var ExecuteStatus = DataEnum.GetEnumData(context, "CF.ExecuteStatus");

                ExecuteModeTextEdit.Properties.DataSource = DataEnum.GetEnumData("treatment");
                riluePriority.DataSource = DataEnum.GetEnumData(context, "CF.Priority");
                repositoryItemExecuteStatusLookUpEdit.DataSource = ExecuteStatus;
                ExecuteStatusTextEdit.Properties.DataSource      = ExecuteStatus;
                this.AddSysOperLogs(this.Text, OperateStatus.查询);
                using (SRBase.BaseServiceClient client = new SRBase.BaseServiceClient())
                {
                    var ret = client.GetCraftsParameterContrastList(context.SessionID);
                    if (ret.IsSuccess)
                    {
                        rilueParameterName.DataSource = ret.Data;
                    }
                    else
                    {
                        ClsMsg.ShowWarningMsg(ret.Message);
                    }
                }
                bgwWait.RunWorkerAsync("LoadTreeData");
            }
            catch (Exception ex)
            {
                Utils.Logger.Error(ex.ToString());
                ClsMsg.ShowErrMsg(ex.Message);
            }
        }
Пример #6
0
 public Data(string name, byte[] data, DataEnum dataType, uint append = 0)
 {
     this.Name     = name;
     this.BINData  = data;
     this.DataType = dataType;
     this.Append   = append;
 }
Пример #7
0
 public frmPullDetectionReg(UserContext context)
     : base(context)
 {
     InitializeComponent();
     bgwWait.ProgressChanged          += this.backgroundWorker_ProgressChanged;
     TProcessType                      = DataEnum.GetEnumData("wd.processtype");
     gridView1.CustomDrawRowIndicator += new GridViewEventTool().GridView_CustomDrawRowIndicator;
 }
Пример #8
0
 public Data(uint orgaddr, DataEnum dataType, uint append = 0)
 {
     this.ORGAddr  = orgaddr;
     this.DataType = dataType;
     this.Append   = append;
     this.Name     = "";
     this.Dir      = "";
 }
Пример #9
0
 public Data(string filename, string dir, byte[] data, DataEnum dataType, uint append = 0)
 {
     this.Name     = filename;
     this.Dir      = dir;
     this.BINData  = data;
     this.DataType = dataType;
     this.Append   = append;
 }
Пример #10
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 private static string MakeColumnSql(string name, DataEnum de)
 {
     string dataColumnName = DataEnumClass.GetDataColumnNameByDataEnum(de);
     string s = string.Format(
         "Max( Case when StationName = '{0}' then {1} end ) as '{0}'",
         name, dataColumnName);
     return s;
 }
Пример #11
0
 void CorrectData(DataEnum type, float ratio)
 {
     this[type] -= (this[type] * ratio).ToInt();
     if (this[type] <= 0)
     {
         this[type] = 1;
     }
 }
Пример #12
0
        string pt = String.Empty; // 父模块类型

        protected void Page_Load(object sender, EventArgs e)
        {
            op = RequestData.Get <string>("op"); // 用户编辑操作
            id = RequestData.Get <string>("id");
            pt = RequestData.Get <string>("pt");

            SysGroup ent = null;

            if (IsAsyncRequest)
            {
                switch (RequestAction)
                {
                case RequestActionEnum.Query:
                case RequestActionEnum.Read:
                case RequestActionEnum.Default:
                    break;

                case RequestActionEnum.Create:
                    ent = this.GetPostedData <SysGroup>();
                    ent.Create();
                    break;

                case RequestActionEnum.Update:
                    ent = this.GetMergedData <SysGroup>();
                    ent.DoUpdate();
                    break;

                case RequestActionEnum.Delete:
                    ent = this.GetTargetData <SysGroup>();
                    ent.DoDelete();
                    break;

                default:
                    if (RequestActionString == "createsub")
                    {
                        ent = this.GetPostedData <SysGroup>();
                        ent.CreateAsSub(id);
                    }
                    break;
                }
            }
            else
            {
                if (op != "c" && op != "cs")
                {
                    if (!String.IsNullOrEmpty(id))
                    {
                        ent = SysGroup.Find(id);
                    }
                }
            }

            DataEnum de = SysGroupTypeRule.GetGroupTypeEnum();

            this.PageState.Add("GrpTypeEnum", de);

            this.SetFormData(ent);
        }
Пример #13
0
 private void radioButtonInputFrench_CheckedChanged(object sender, EventArgs e)
 {
     if (_SuspendEvents)
     {
         return;
     }
     _Input = DataEnum.French;
     DataToStartUI();
 }
Пример #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        static private string MakeColumnSql(string name, DataEnum de)
        {
            string dataColumnName = DataEnumClass.GetDataColumnNameByDataEnum(de);
            string s = string.Format(
                "Max( Case when StationName = '{0}' then {1} end ) as '{0}'",
                name, dataColumnName);

            return(s);
        }
Пример #15
0
 private void frmArrangedVouch_Load(object sender, EventArgs e)
 {
     try
     {
         UserStatusLookUpEdit.Properties.DataSource = DataEnum.GetEnumData(context, "CF.UserStatus");
     }
     catch (Exception ex) { Utils.Logger.Error(ex.ToString()); }
     bgwWait.RunWorkerAsync();
 }
Пример #16
0
        bool ParsePng2Dmp(string line, string orignalIine)
        {
            string a = Keyword(line, "#incext Png2Dmp");

            if (a == "")
            {
                return(false);
            }
            string filename    = U.cut(a, "\"", "\"");
            string fullbinname = Path.Combine(this.Dir, filename);

            if (!File.Exists(fullbinname))
            {
                return(false);
            }

            DataEnum dataType = DataEnum.BIN;

            if (orignalIine.IndexOf("--lz77") >= 0)
            {
                byte[] image = Png2DmpLZ77(fullbinname);
                Data   data  = new Data(filename, image, dataType);
                this.DataList.Add(data);
            }

            string errorMessage;
            Bitmap bitmap = ImageUtil.OpenBitmap(fullbinname, null, out errorMessage);

            if (bitmap == null)
            {
                return(false);
            }
            if (bitmap.Width < 8 || bitmap.Height < 8)
            {
                bitmap.Dispose();
                return(false);
            }

            if (orignalIine.IndexOf("--palette-only") >= 0)
            {//パレットのみ
                byte[] palette = ImageUtil.ImageToPalette(bitmap, 1);

                Data data = new Data(filename, palette, dataType);
                this.DataList.Add(data);
            }
            else
            {
                byte[] image = ImageUtil.ImageToByte16Tile(bitmap, bitmap.Width, bitmap.Height);

                Data data = new Data(filename, image, dataType);
                this.DataList.Add(data);
            }

            bitmap.Dispose();

            return(true);
        }
        internal void GMLoadUser(string gmAccount, ulong userGuid, LobbyGmMessageDefine jsonMsgId, int nodeHandle)
        {
            string      key = userGuid.ToString();
            Msg_LD_Load msg = new Msg_LD_Load();

            msg.MsgId = (int)DataEnum.TableUserInfo;
            msg.PrimaryKeys.Add(key);
            Msg_LD_SingleLoadRequest reqUser = new Msg_LD_SingleLoadRequest();

            reqUser.MsgId    = (int)DataEnum.TableUserInfo;
            reqUser.LoadType = Msg_LD_SingleLoadRequest.LoadTypeEnum.LoadSingle;
            reqUser.Keys.Add(key);
            msg.LoadRequests.Add(reqUser);
            RequestLoad(msg, (ret) => {
                JsonMessage resultMsg = new JsonMessage(jsonMsgId, gmAccount);
                GameFrameworkMessage.Msg_LC_GmQueryUser protoData = new GameFrameworkMessage.Msg_LC_GmQueryUser();
                protoData.m_Result = GameFrameworkMessage.GmResultEnum.Failed;
                protoData.m_Info   = null;

                KeyString primaryKey = KeyString.Wrap(ret.PrimaryKeys);
                if (Msg_DL_LoadResult.ErrorNoEnum.Success == ret.ErrorNo)
                {
                    LogSys.Log(LOG_TYPE.INFO, "DataCache Load Success: Msg:{0}, Key:{1}", "GmUser", primaryKey);
                    TableUserInfo dataUser = null;
                    foreach (var result in ret.Results)
                    {
                        object _msg;
                        if (DbDataSerializer.Decode(result.Data, DataEnum2Type.Query(result.MsgId), out _msg))
                        {
                            DataEnum msgEnum = (DataEnum)result.MsgId;
                            switch (msgEnum)
                            {
                            case DataEnum.TableUserInfo:
                                dataUser = _msg as TableUserInfo;
                                break;

                            default:
                                LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "Decode user data ERROR. Wrong message id. UserGuid:{0}, WrongId:{1}", userGuid, msgEnum);
                                break;
                            }
                        }
                    }
                    protoData.m_Result = GameFrameworkMessage.GmResultEnum.Success;
                    protoData.m_Info   = CreateGmUserInfo(dataUser);
                }
                else if (Msg_DL_LoadResult.ErrorNoEnum.NotFound == ret.ErrorNo)
                {
                    LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Yellow, "DataCache Load NotFound: Msg:{0}, Key:{1}", "GmUser", primaryKey);
                }
                else
                {
                    LogSys.Log(LOG_TYPE.ERROR, "DataCache Load Failed: Msg:{0}, Key:{1}, ERROR:{2}", "GmUser", primaryKey, ret.ErrorInfo);
                }
                resultMsg.m_ProtoData = protoData;
                JsonGmMessageDispatcher.SendNodeMessage(nodeHandle, resultMsg);
            });
        }
Пример #18
0
        private DotNet.Highcharts.Highcharts GetChart(Series[] series, DataEnum data)
        {
            Chart       chart   = null;
            XAxis       xAxis   = null;
            PlotOptions options = null;

            switch (data)
            {
            case DataEnum.random_points:
                xAxis = new XAxis {
                    Categories = new[] { "50", "100", "500", "1k", "5k", "10k", "50k", "100k", "500k", "1M", "2M", "3M", "4M", "5M" }
                };
                options = new PlotOptions();
                chart   = new Chart();
                break;

            case DataEnum.countries:
                xAxis = new XAxis {
                    Categories = series.Select(t => t.Name).ToArray()
                };
                options = new PlotOptions {
                    Column = new PlotOptionsColumn {
                        Stacking = Stackings.Normal
                    }
                };
                chart = new Chart {
                    DefaultSeriesType = ChartTypes.Column
                };

                // ReSharper disable once PossibleNullReferenceException
                var results = new object[series.Length];
                for (int i = 0; i < series.Length; i++)
                {
                    results[i] = series.FirstOrDefault(x => x.Name.Equals(series[i].Name)).Data.ArrayData[0];
                }
                series = new[] { new Series {
                                     Name = data.ToString(), Data = new Data(results)
                                 } };

                break;
            }

            return(new DotNet.Highcharts.Highcharts("chart")
                   .InitChart(chart)
                   .SetTitle(new Title {
                Text = "Comparison result"
            })
                   .SetXAxis(xAxis)
                   .SetYAxis(new YAxis {
                Title = new YAxisTitle {
                    Text = "Time (ms)"
                },
            })
                   .SetSeries(series)
                   .SetPlotOptions(options));
        }
Пример #19
0
 private void frmQCDrumsFindLeak_Load(object sender, EventArgs e)
 {
     try
     {
         var FLSituationData = DataEnum.GetEnumData(context, "CF.FLSituation");
         FLSituationTextEdit.Properties.DataSource = FLSituationData;
         BgWait.RunWorkerAsync("SearchData2");//打开窗口显示列表数据
     }
     catch (Exception ex) { Utils.Logger.Error(ex.ToString()); }
 }
Пример #20
0
 /// <summary>
 /// Accepts the changes to this data class.
 /// </summary>
 public void AcceptChanges()
 {
     this.unchangedDataClass.boolProperty     = this.boolProperty;
     this.unchangedDataClass.dateTimeProperty = this.dateTimeProperty;
     this.unchangedDataClass.enumProperty     = this.enumProperty;
     this.unchangedDataClass.intProperty      = this.intProperty;
     this.unchangedDataClass.intPropertyWithoutAutoGenerateField = this.intPropertyWithoutAutoGenerateField;
     this.unchangedDataClass.nonGeneratedIntProperty             = this.nonGeneratedIntProperty;
     this.unchangedDataClass.stringProperty = this.stringProperty;
     this.IsChanged = false;
 }
Пример #21
0
        public void ReLoad(DataEnum dataClass)
        {
            //重新读取数据
            DataTable table = BaseDal.GetDataTable(dataClass);
            Data      data  = new Data(table);

            if (htDatas.ContainsKey(dataClass))
            {
                htDatas.Remove(dataClass);
            }
            htDatas.Add(dataClass, data);
        }
Пример #22
0
//
//		private static CompareStrSort cSort;
//
//		private static CompareStrEnum[] c1 =
//		{
//			REV_MGMT_RECORD_ID, REV_SELECTED, REV_SEQ, REV_SORT_ITEM_REVID,
//			REV_SORT_ORDER_CODE, REV_SORT_DELTA_TITLE, REV_SORT_SHEETNUM,
//			REV_ITEM_VISIBLE, REV_ITEM_BLOCK_TITLE, REV_ITEM_DATE,
//			REV_SORT_ITEM_BASIS, REV_SORT_ITEM_DESC, REV_TAG_ELEM_ID, REV_CLOUD_ELEM_ID,
//			cSort,
//		};
//
//		private static CompareStrSort[] c2 =
//		{
//			REV_MGMT_RECORD_ID, REV_SELECTED, REV_SEQ, REV_SORT_ITEM_REVID,
//			REV_SORT_ORDER_CODE, REV_SORT_DELTA_TITLE, REV_SORT_SHEETNUM,
//			REV_ITEM_VISIBLE, REV_ITEM_BLOCK_TITLE, REV_ITEM_DATE,
//			REV_SORT_ITEM_BASIS, REV_SORT_ITEM_DESC, REV_TAG_ELEM_ID, REV_CLOUD_ELEM_ID,
//			cSort,
//		};


        #endregion

        #region + Utility

        public static DataEnum Clone(this DataEnum item)
        {
            DataEnum copy = new DataEnum(item.DescItemIdx, item.DataIdx);

//			copy.Column  = item.Column;
            copy.Source  = item.Source;
            copy.Name    = item.Name;
            copy.Display = item.Display.Clone();
            copy.Title   = item.Title;
            copy.Type    = item.Type;

            return(copy);
        }
Пример #23
0
        private void frmCPContrastList_Load(object sender, EventArgs e)
        {
            bgwWait.RunWorkerAsync("LoadData");
            var ParamTypeData = DataEnum.GetEnumData(context, "CF.ParamType");

            if (ParamTypeData.Count > 0)
            {
                ParamTypeData.ForEach(t =>
                {
                    this.repositoryItemComboBox1.Items.Add(t.Item1);
                });
            }
        }
        /// <summary>
        /// 获取模块类型枚举
        /// </summary>
        public static DataEnum GetModuleTypeEnum()
        {
            DataEnum de = new DataEnum();

            SysModuleType[] sml = SysModuleType.FindAll();

            foreach (SysModuleType sm in sml)
            {
                de.Add(sm.ModuleTypeID.ToString(), sm.Name);
            }

            return(de);
        }
Пример #25
0
        /// <summary>
        /// 窗体打开加载数据
        /// </summary>     
        private void Interface_Load(object sender, EventArgs e)
        {
            this.AddSysOperLogs(this.Text, OperateStatus.查询);
            this.WindowState = FormWindowState.Maximized;
            client = new SRDevice.DeviceServiceClient();
            bgwWait1.RunWorkerAsync("SearchData");
            lstUserStatus = DataEnum.GetEnumData("status");
            UserStatusEdit.Properties.DataSource = lstUserStatus;
            UserStatusEdit.EditValue = -1;
            this.DeviCodeTextEdit.Properties.ReadOnly = true;
            this.bbtnSave.Enabled = false;

        }
        /// <summary>
        /// 获取类型枚举
        /// </summary>
        public static DataEnum GetAuthTypeEnum()
        {
            DataEnum de = new DataEnum();

            SysAuthType[] types = SysAuthType.FindAll();

            foreach (SysAuthType type in types)
            {
                de.Add(type.AuthTypeID.ToString(), type.Name);
            }

            return(de);
        }
        /// <summary>
        /// 获取枚举
        /// </summary>
        public static DataEnum GetGroupTypeEnum()
        {
            DataEnum de = new DataEnum();

            SysGroupType[] ents = SysGroupType.FindAll();

            foreach (SysGroupType ent in ents)
            {
                de.Add(ent.GroupTypeID.ToString(), ent.Name);
            }

            return(de);
        }
 public static Query Get(QueryEnum queryEnum, IndexEnum index, DataEnum data, DataSizeEnum size, Random random)
 {
     switch (queryEnum)
     {
         case QueryEnum.FindPointsNearRandomPoints:
             return new FindPointsNearRandomPointsQuery(index, data, size, random);
         case QueryEnum.FindNearestNeighbours:
             return new FindNearestNeighboursQuery(index, data, size, random);
         case QueryEnum.TouchesAllToAll:
             return new TouchesAllToAllQuery(index, data, size, random);
     }
     return null;
 }
Пример #29
0
        /// <summary>
        /// 获取年报表数据
        /// </summary>
        /// <param name="year"></param>
        /// <param name="device"></param>
        /// <param name="de">数据标识</param>
        /// <returns></returns>
        static public DataTable ExecuteYearDataTable(int year, DeviceClass device, DataEnum de)
        {
            if (device == null)
            {
                throw new ArgumentNullException("station");
            }

            int      deviceid = device.DeviceID;
            DateTime b        = new DateTime(year, 1, 1);
            DateTime e        = new DateTime(year + 1, 1, 1);
            string   s        = string.Format(
                "select * from tblDitchDataDay where deviceid = {0} and dt >= '{1}' and dt < '{2}' order by dt",
                deviceid, b, e);

            DataTable tbl       = DBI.GetDBI().ExecuteDataTable(s);
            DataTable destTable = CreateDestDataTable();

            //
            //
            foreach (DataRow row in tbl.Rows)
            {
                DateTime dt         = Convert.ToDateTime(row["dt"]);
                int      month      = dt.Month;
                int      day        = dt.Day;
                string   columnName = GetColumnName(de);
                int      value      = Convert.ToInt32(row[columnName]);

                int rowIndex = day - 1;
                // riqi 1 2 3 4 5 ... 12
                //
                int     colIndex = month;
                DataRow destRow  = destTable.Rows[rowIndex];
                destRow[colIndex] = value;
            }

            switch (de)
            {
            case DataEnum.WL:
            case DataEnum.Flux:
                DataTableHelper.AddAvgRow(destTable, 1, new object[] { "平均" });
                break;

            case DataEnum.Amount:
                DataTableHelper.AddSumRow(destTable, 1, new object[] { "合计" });
                break;

            default:
                break;
            }
            return(destTable);
        }
Пример #30
0
 private void frmArrangedVouch_Load(object sender, EventArgs e)
 {
     try
     {
         var UserStatusData = DataEnum.GetEnumData(context, "CF.UserStatus");
         UserStatusLookUpEdit.DataSource           = UserStatusData;
         UseStatusLookUpEdit.Properties.DataSource = UserStatusData;
         UseStatusLookUpEdit.EditValue             = "1";
     }
     catch (Exception ex)
     {
         Utils.Logger.Error(ex.ToString());
     }
 }
Пример #31
0
 /// <summary>
 /// Begins an edit.
 /// </summary>
 public void BeginEdit()
 {
     if (this.oldDataClass == null)
     {
         this.oldDataClass = new DataClassWithEnum();
         this.oldDataClass.boolProperty     = this.boolProperty;
         this.oldDataClass.dateTimeProperty = this.dateTimeProperty;
         this.oldDataClass.enumProperty     = this.enumProperty;
         this.oldDataClass.intProperty      = this.intProperty;
         this.oldDataClass.intPropertyWithoutAutoGenerateField = this.intPropertyWithoutAutoGenerateField;
         this.oldDataClass.nonGeneratedIntProperty             = this.nonGeneratedIntProperty;
         this.oldDataClass.stringProperty = this.stringProperty;
     }
 }
Пример #32
0
 /// <summary>
 /// Initializes the unchanged data class used in IRevertableChangeTracking.
 /// </summary>
 private void EnsureUnchangedDataClass()
 {
     if (this.unchangedDataClass == null)
     {
         this.unchangedDataClass = new DataClassWithEnum();
         this.unchangedDataClass.boolProperty     = this.boolProperty;
         this.unchangedDataClass.dateTimeProperty = this.dateTimeProperty;
         this.unchangedDataClass.enumProperty     = this.enumProperty;
         this.unchangedDataClass.intProperty      = this.intProperty;
         this.unchangedDataClass.intPropertyWithoutAutoGenerateField = this.intPropertyWithoutAutoGenerateField;
         this.unchangedDataClass.nonGeneratedIntProperty             = this.nonGeneratedIntProperty;
         this.unchangedDataClass.stringProperty = this.stringProperty;
     }
 }
Пример #33
0
        /// <summary>
        /// 获取年报表数据
        /// </summary>
        /// <param name="year"></param>
        /// <param name="device"></param>
        /// <param name="de">数据标识</param>
        /// <returns></returns>
        public static DataTable ExecuteYearDataTable(int year, DeviceClass device, DataEnum de)
        {
            if (device == null)
            {
                throw new ArgumentNullException("station");
            }

            int deviceid = device.DeviceID;
            DateTime b = new DateTime(year, 1, 1);
            DateTime e = new DateTime(year + 1, 1, 1);
            string s = string.Format(
                "select * from tblDitchDataDay where deviceid = {0} and dt >= '{1}' and dt < '{2}' order by dt",
                deviceid, b, e);

            DataTable tbl = DBI.GetDBI().ExecuteDataTable(s);
            DataTable destTable = CreateDestDataTable();
            //
            //
            foreach (DataRow row in tbl.Rows)
            {
                DateTime dt = Convert.ToDateTime(row["dt"]);
                int month = dt.Month;
                int day = dt.Day;
                string columnName = GetColumnName(de);
                int value = Convert.ToInt32(row[columnName ]);

                int rowIndex = day - 1;
                // riqi 1 2 3 4 5 ... 12
                //
                int colIndex = month;
                DataRow destRow = destTable.Rows[rowIndex];
                destRow[colIndex] = value;
            }

            switch (de)
            {
                case DataEnum.WL :
                case DataEnum.Flux :
                    DataTableHelper.AddAvgRow(destTable, 1, new object[] { "平均" });
                    break;
                case DataEnum.Amount :
                    DataTableHelper.AddSumRow(destTable, 1, new object[] { "合计" });
                    break;

                default:
                    break;
            }
            return destTable;
        }
Пример #34
0
        private void SetVisualState()
        {
            if (AssociatedObject == null || DataEnum == null)
            {
                return;
            }
            var stateName = String.IsNullOrEmpty(FinalStateNameFormat) ? DataEnum.ToString() : String.Format(FinalStateNameFormat, DataEnum.ToString());

            if (StateTarget == null)
            {
                return;
            }
            HookUptoCompletedEvent(StateTarget, stateName);
            VisualStateUtilities.GoToState(StateTarget, stateName, UseTransitions);
        }
Пример #35
0
        public static Query Get(QueryEnum queryEnum, IndexEnum index, DataEnum data, DataSizeEnum size, Random random)
        {
            switch (queryEnum)
            {
            case QueryEnum.FindPointsNearRandomPoints:
                return(new FindPointsNearRandomPointsQuery(index, data, size, random));

            case QueryEnum.FindNearestNeighbours:
                return(new FindNearestNeighboursQuery(index, data, size, random));

            case QueryEnum.TouchesAllToAll:
                return(new TouchesAllToAllQuery(index, data, size, random));
            }
            return(null);
        }
Пример #36
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="de"></param>
        /// <returns></returns>
        static private string GetColumnName(DataEnum de)
        {
            switch (de)
            {
            case DataEnum.WL:
                return("AVGWL");

            case DataEnum.Flux:
                return("AVGFlux");

            case DataEnum.Amount:
                return("DayAmount");

            default:
                throw new ArgumentException("cannot find column name by '" + de + "'");
            }
        }
Пример #37
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="names"></param>
        /// <returns></returns>
        private static string MakeColumns(string[] names, DataEnum de)
        {
            if (names == null || names.Length == 0)
                throw new ArgumentException("names null or length == 0");

            string s = string.Empty ;
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < names.Length - 1; i++)
            {
                s = MakeColumnSql(names[i], de);
                sb.Append(s + ",");
            }

            s = MakeColumnSql(names[names.Length - 1], de);
            sb.Append(s);

            return sb.ToString();
        }
 public FindPointsNearRandomPointsQuery(
     IndexEnum index, 
     DataEnum data, 
     DataSizeEnum dataSize,
     Random random,
     int numberOfPoints = 1,
     double distance = 1,
     bool andOr = false
     )
     : base(index, dataSize)
 {
     this._random = random;
     this._distance = distance;
     this._numberOfPoints = numberOfPoints;
     this._andOr = andOr;
     this._data = data;
     this._qgisPathPrefix = ConfigurationManager.AppSettings["QgisPathPrefix"];
 }
        public void CreateTable(DataSizeEnum dataSize, DataEnum data)
        {
            string tableName = data.ToString();
            tableName += (dataSize == DataSizeEnum.None ? string.Empty : "_" + (int)dataSize);

            string createTableCommandText =
            @"DO
            $BODY$
            DECLARE
            i INT := 0;
            BEGIN
            IF NOT EXISTS
            (
            SELECT 1
            FROM   pg_class c
            JOIN   pg_namespace n ON n.oid = c.relnamespace
            WHERE  c.relname = '"+tableName+@"'
            AND    n.nspname = 'public'
            )
            THEN
            CREATE TABLE " + tableName + @"
            (
            id serial NOT NULL,
            geom geometry,
            CONSTRAINT " + tableName + @"_pk PRIMARY KEY (id),
            CONSTRAINT enforce_geotype_geom CHECK (geometrytype(geom) = 'POINT'::text OR geom IS NULL),
            CONSTRAINT enforce_srid_geom CHECK (st_srid(geom) = 4326)
            ) WITH (OIDS=FALSE);
            ALTER TABLE " + tableName + @" OWNER TO postgres;

            " + (data != DataEnum.countries ? @"
            FOR i IN 1.." + (int)dataSize + @"
            LOOP
            INSERT INTO " + tableName + @"(geom)
                VALUES (ST_SetSRID(ST_MakePoint((random()*360)-180, (random()*180-90)), 4326));
            END LOOP;" : string.Empty) + @"
            END IF;
            END
            $BODY$;";

            using (var command = new NpgsqlCommand(createTableCommandText, _conn))
                command.ExecuteNonQuery();
        }
 public TouchesAllToAllQuery(
     IndexEnum index, 
     DataEnum data,
     DataSizeEnum dataSize,
     Random random,
     int numberOfPoints = 1,
     double distance = 1,
     bool andOr = false,
     int nearestNeighboursCount = 5
     )
     : base(index, dataSize)
 {
     this._data = data;
     this._random = random;
     this._distance = distance;
     this._numberOfPoints = numberOfPoints;
     this._andOr = andOr;
     this._nearestNeighboursCount = nearestNeighboursCount;
     this._qgisPathPrefix = ConfigurationManager.AppSettings["QgisPathPrefix"];
 }
Пример #41
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="de"></param>
        /// <returns></returns>
        public static string GetDataColumnNameByDataEnum(DataEnum de)
        {
            string n = string.Empty;
            switch (de)
            {
                case DataEnum.WL :
                    n = "AVGWL";
                    break;

                case DataEnum.Flux :
                    n = "AVGFlux";
                    break;

                case DataEnum.Amount :
                    n = "DayAmount";
                    break;
                default :
                    throw new ArgumentException("cannot find datacolumn name by dataenum : " + de );
            }

            return n;
        }
        private Series GetSeries(QueryEnum queryEnum, IndexEnum index, Random random, int times, DataEnum dataEnum)
        {
            var data = new List<object>();
            if (dataEnum == DataEnum.countries)
            {
                var speed = GetIndexSpeed(QueryFactory.Get(queryEnum, index, dataEnum, DataSizeEnum.None, random), times);
                data.Add(speed);
            }
            else
            {
                foreach (var value in Enum.GetValues(typeof(DataSizeEnum)))
                {
                    if((DataSizeEnum)value == DataSizeEnum.None) continue;
                    var speed = GetIndexSpeed(QueryFactory.Get(queryEnum, index, dataEnum, (DataSizeEnum)value, random), times);
                    if (speed.Equals(-1.0d))
                        break;
                    data.Add(speed);
                }
            }

            return new Series
                   {
                       Name = index.ToString(),
                       Data = new Data(data.ToArray())
                   };
        }
Пример #43
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="de"></param>
        /// <returns></returns>
        public static string GetDataEnumUnit( DataEnum de )
        {
            string n = string.Empty ;
            switch (de)
            {
                case DataEnum.WL :
                    n = "cm";
                    break;

                case DataEnum.Flux :
                    n = "m3/s";
                    break;

                case DataEnum.Amount :
                    n = "m3";
                    break;
                default :
                    break;
            }

            return n;
        }
Пример #44
0
 protected string QueryResultToAlertType(DataEnum.QueryResult q)
 {
     switch (q)
     {
         case DataEnum.QueryResult.Success:
             return Constants.AlertType.SUCCESS;
         case DataEnum.QueryResult.Duplicate:
             return Constants.AlertType.WARNING;
     }
     return Constants.AlertType.DANGER;
 }
Пример #45
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="begin"></param>
        /// <param name="end"></param>
        /// <param name="stationNames"></param>
        /// <returns></returns>
        private static string MakeSql(DateTime begin, DateTime end, string[] stationNames, DataEnum de)
        {
            // 0
            string columns = MakeColumns(stationNames, de);
            string nameWhere = MakeWheres(stationNames);

            string s =
                "select DT, {0} from vDitchDataDay where (dt >= '{1}' and dt < '{2}') " +
                " and {3} group by DT order by DT";
            s = string.Format(s, columns, begin, end, nameWhere);
            return s;
        }
Пример #46
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="de"></param>
        private void ToSamePage(DataEnum de)
        {
            ChannelStationDTCondition c = new ChannelStationDTCondition();
            c.ChannelCollection = this.UCCompareAmount1.SelectedChannelCollection;
            c.StationCollection  = this.UCCompareAmount1.SelectedStationCollection;
            c.Begin = this.UCCompareAmount1.Begin;
            c.End = this.UCCompareAmount1.End;
            c.DataEnum = de;

            Guid guid = Guid.NewGuid();
            string guidstring = guid.ToString();
            Session[guidstring] = c;

            string url = string.Format("pDataHistroy2.aspx?id={0}", guidstring);
            WindowsHelper.OpenInNewWindows(this.Response, url);

            this.Query();
        }
Пример #47
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="de"></param>
 /// <returns></returns>
 private static string GetColumnName(DataEnum de)
 {
     switch (de)
     {
         case DataEnum.WL :
             return "AVGWL";
         case DataEnum .Flux :
             return "AVGFlux";
         case DataEnum.Amount:
             return "DayAmount";
         default :
             throw new ArgumentException("cannot find column name by '" + de + "'");
     }
 }
Пример #48
0
        /// <summary>
        /// 
        /// 
        /// </summary>
        /// <param name="de"></param>
        /// <returns></returns>
        public static string GetDataEnumTitle(DataEnum de)
        {
            string n = string.Empty;
            switch (de)
            {
                case DataEnum.WL :
                    n = "水位查询";
                    break;

                case DataEnum.Flux :
                    n = "流量查询";
                    break;

                case DataEnum.Amount :
                    n = "水量查询";
                    break;
                default :
                    throw new ArgumentException("cannot find datenum string by dataenum : " + de );
            }

            return n;
        }
Пример #49
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        private GridViewConfig GetGridViewConfig(DataEnum de, DataTable dataSourceDataTable)
        {
            if( dataSourceDataTable == null )
            {
                throw new ArgumentNullException ("dataSourceDataTable");
            }

            GridViewConfig c = new GridViewConfig();
            c.GridViewColumnConfigCollection.AddBoundField(strings.ChannelName, "ChannelName");
            c.GridViewColumnConfigCollection.AddBoundField(strings.StationName, "StationName");
            c.GridViewColumnConfigCollection.AddBoundField(strings.DT , "DT");
            string t = string.Empty;
            switch (de)
            {
                case DataEnum.WL:
                    t = DataTableHelper.GetExistColumnName(dataSourceDataTable, "WL1", "AVGWL");
                    c.GridViewColumnConfigCollection.AddBoundField(strings.WLWithUnit , t);
                    break;

                case DataEnum.Flux:
                    t =  DataTableHelper.GetExistColumnName(dataSourceDataTable, "InstantFlux", "avgflux");
                    //c.GridViewColumnConfigCollection.AddBoundField(strings.InstantFlux , "InstantFlux");
                    GridViewColumnConfig columnConfig = c.GridViewColumnConfigCollection.AddBoundField(
                        strings.InstantFluxWithUnit, t, FormatStringManager.FloatValueFormatString);
                    break;

                case DataEnum.Amount:
                    t = DataTableHelper.GetExistColumnName(dataSourceDataTable, "DayAmount");
                    c.GridViewColumnConfigCollection.AddBoundField(strings.AmountWithUnit, t,
                        FormatStringManager.FloatValueFormatString);
                    break;
            }
            //
            //
            c.AllowSorting = true;
            return c;
        }
 /// <summary>
 /// Initializes the unchanged data class used in IRevertableChangeTracking.
 /// </summary>
 private void EnsureUnchangedDataClass()
 {
     if (this.unchangedDataClass == null)
     {
         this.unchangedDataClass = new DataClassWithEnum();
         this.unchangedDataClass.boolProperty = this.boolProperty;
         this.unchangedDataClass.dateTimeProperty = this.dateTimeProperty;
         this.unchangedDataClass.enumProperty = this.enumProperty;
         this.unchangedDataClass.intProperty = this.intProperty;
         this.unchangedDataClass.intPropertyWithoutAutoGenerateField = this.intPropertyWithoutAutoGenerateField;
         this.unchangedDataClass.nonGeneratedIntProperty = this.nonGeneratedIntProperty;
         this.unchangedDataClass.stringProperty = this.stringProperty;
     }
 }
 /// <summary>
 /// Begins an edit.
 /// </summary>
 public void BeginEdit()
 {
     if (this.oldDataClass == null)
     {
         this.oldDataClass = new DataClassWithEnum();
         this.oldDataClass.boolProperty = this.boolProperty;
         this.oldDataClass.dateTimeProperty = this.dateTimeProperty;
         this.oldDataClass.enumProperty = this.enumProperty;
         this.oldDataClass.intProperty = this.intProperty;
         this.oldDataClass.intPropertyWithoutAutoGenerateField = this.intPropertyWithoutAutoGenerateField;
         this.oldDataClass.nonGeneratedIntProperty = this.nonGeneratedIntProperty;
         this.oldDataClass.stringProperty = this.stringProperty;
     }
 }
        public void RemoveIndex(IndexEnum index, DataSizeEnum dataSize, DataEnum data)
        {
            string indexName = data.ToString();
            indexName += (dataSize == DataSizeEnum.None ? string.Empty : "_" + (int)dataSize);
            indexName += "_" + index + @"_idx";

            if (data == DataEnum.countries)
            {
                if (index == IndexEnum.gist)
                    indexName = "countries_geom_gist";
                else return;
            }

            string dropIndexCommandText = @"DROP INDEX IF EXISTS " + indexName;

            using (var command = new NpgsqlCommand(dropIndexCommandText, _conn))
                command.ExecuteNonQuery();
        }
        public void EnableIndex(IndexEnum index, DataSizeEnum dataSize, DataEnum data)
        {
            string indexName = data.ToString();
            indexName += (dataSize == DataSizeEnum.None ? string.Empty : "_" + (int)dataSize);
            indexName += "_" + index + @"_idx";

            if (data == DataEnum.countries)
            {
                if (index == IndexEnum.gist)
                    indexName = "countries_geom_gist";
                else return;
            }

            string dropIndexCommandText = @"UPDATE pg_index SET indislive = true, indisvalid = true where indexrelid = '" + indexName + @"'::regclass;";
            int rowsChanged;
            using (var command = new NpgsqlCommand(dropIndexCommandText, _conn))
                rowsChanged = command.ExecuteNonQuery();
            if (rowsChanged != 1) throw new Exception("Nieudana kwerenda - " + dropIndexCommandText);
        }
 /// <summary>
 /// Accepts the changes to this data class.
 /// </summary>
 public void AcceptChanges()
 {
     this.unchangedDataClass.boolProperty = this.boolProperty;
     this.unchangedDataClass.dateTimeProperty = this.dateTimeProperty;
     this.unchangedDataClass.enumProperty = this.enumProperty;
     this.unchangedDataClass.intProperty = this.intProperty;
     this.unchangedDataClass.intPropertyWithoutAutoGenerateField = this.intPropertyWithoutAutoGenerateField;
     this.unchangedDataClass.nonGeneratedIntProperty = this.nonGeneratedIntProperty;
     this.unchangedDataClass.stringProperty = this.stringProperty;
     this.IsChanged = false;
 }