public List <Law> ConvertToLaws()
        {
            List <Law> laws = new List <Law>();

            foreach (listItem list in this.data.list)
            {
                Law law = new Law();
                law.Id            = Guid.NewGuid().ToString();
                law.userId        = Global.user.Id;
                law.lawId         = list.id.ToString();
                law.title         = list.title;
                law.version       = list.version;
                law.digest        = list.abs;
                law.weijie        = list.bookType;
                law.buhao         = list.buhao;
                law.effectiveDate = UTC.ConvertIntDatetime(list.startDate).ToString("yyyy-MM-dd HH:mm:ss");
                law.expiryDate    = UTC.ConvertIntDatetime(list.endDate).ToString("yyyy-MM-dd HH:mm:ss");
                law.linghao       = list.linghao;
                law.siju          = list.managerOrg;
                law.status        = list.status;
                law.lastversion   = list.lastversion;
                law.zefa          = list.punish;
                law.yilai         = list.related;
                law.banwendanwei  = list.release;
                law.userLabel     = list.tag; //string.Join(",", list.tagList.Select(t => t.desc));
                law.yewu          = list.biz; //string.Join(",", list.bizList.Select(b => b.desc));
                law.isLocal       = "0";
                laws.Add(law);
            }
            return(laws);
        }
Exemple #2
0
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Export_Click(object sender, RoutedEventArgs e)
        {
            Ga_Map ga_Map = SelectMap();

            if (ga_Map == null)
            {
                return;
            }

            Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
            sfd.Filter   = "地图信息文件|*.tll";
            sfd.FileName = "" + ga_Map.Name + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss");
            if (sfd.ShowDialog() == true)
            {
                if (mapService.Export_Map(UTC.ConvertDateTimeLong(Convert.ToDateTime(ga_Map.CreateTime)), sfd.FileName))
                {
                    GetMaps.ToList().ForEach(x => x.IsSelected = false); //取消选择
                    Map_action.Invoke();                                 //刷新主界面
                    MessageBox.Show("导出成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Asterisk, MessageBoxResult.No);
                }
                else
                {
                    MessageBox.Show("导出失败!", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.No);
                }
            }
        }
 public async Task Execute(IJobExecutionContext context)
 {
     try
     {
         if (connectionManager.GetCount() > 0)
         {
             foreach (var WebSocketitem in connectionManager.GetAll().Values)
             {
                 long interval = UTC.ConvertDateTimeLong(DateTime.Now) - UTC.ConvertDateTimeLong(WebSocketitem.HeartbeatTime);
                 if (interval >= 60)
                 {
                     await connectionManager.RemoveSocket(WebSocketitem.Guid);
                 }
                 else if (interval >= 10)
                 {
                     WebSocketitem.connectstate = false;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         logger.LogError(ex.Message, ex);
     }
 }
Exemple #4
0
 private void Line_Delete_Click(object sender, RoutedEventArgs e)
 {
     if (edit)
     {
         MessageBoxResult confirmToDel = MessageBox.Show("确认要删除线路吗?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (confirmToDel == MessageBoxResult.Yes)
         {
             if (mapService.DelRouteMapSystem(UTC.ConvertDateTimeLong(Convert.ToDateTime(MapMenu.SelectedValue.ToString())), RouteData.Program))
             {
                 Task.Factory.StartNew(() =>
                 {
                     GetRoutes = mapService.GetrouteList(UTCTime.ToString());
                     this.Dispatcher.BeginInvoke(new Action(() => { Line.ItemsSource = GetRoutes; Line.SelectedIndex = 0; }));
                 });
                 MessageBox.Show("删除成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
             }
             else
             {
                 MessageBox.Show("删除失败!", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
     }
     else
     {
         Line_Add_Click(null, null);
     }
 }
Exemple #5
0
        /// <summary>
        /// 保存地图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            int TypeID = 0;

            if (TypeMp.SelectedIndex.Equals(0))
            {
                TypeID = 1;
            }
            else if (TypeMp.SelectedIndex.Equals(1))
            {
                TypeID = 0;
            }
            else
            {
                TypeID = 2;
            }
            bool mp = map.SaveAtlas((!Time.Equals(0) ? Time.ToString() : UTC.ConvertDateTimeLong(DateTime.Now).ToString()), !Time.Equals(0) ? false : true, MP.Text, (GrnWidth / 10), (GrnMpHeight / 10), "0", TypeID);

            if (mp)
            {
                MessageBox.Show("保存成功");
            }
            else
            {
                MessageBox.Show("保存失败");
            }
        }
 /// <summary>
 /// Verbose variant of <see cref="ToString"/> that includes ALL properties.
 /// </summary>
 public string ToStringFull()
 {
     return("[" + UTC.ToLocalTime().ToString("HH:mm:ss.fff") + "] "
            + "[" + Sender.GetType().Name + "] "
            + "[" + Level.ToString().ToUpperInvariant() + "] "
            + Message
            + (Exception == null ? "" : "\n" + Exception));
 }
Exemple #7
0
        // 圆所在矩形的左上角点坐标x, y; 直径dia; which: 0(北京时间), 1(世界统一时间)
        private void DrawClock(Graphics g, int x, int y, int dia, int hour, int minu, int sec, bool which)
        {
            // 绘制表盘
            g.DrawEllipse(giveMePen(Color.Black, 1), x, y, dia, dia);

            // 得到秒针、分针、时针终点位置
            int   rad      = dia / 2;
            Point center   = new Point(x + rad, y + rad);
            Point secPoint = new Point((int)(center.X + (Math.Sin(sec * PI / 30) * (rad / 10 * 9))),
                                       (int)(center.Y - (Math.Cos(sec * PI / 30) * (rad / 10 * 9))));
            Point minPoint = new Point((int)(center.X + (Math.Sin(minu * PI / 30) * (rad / 10 * 7))),
                                       (int)(center.Y - (Math.Cos(minu * PI / 30) * (rad / 10 * 7))));
            Point hourPoint = new Point((int)(center.X + (Math.Sin((hour + (double)minu / 60) * PI / 12) * (rad / 10 * 5))),
                                        (int)(center.Y - (Math.Cos((hour + (double)minu / 60) * PI / 12) * (rad / 10 * 5))));

            // 显示时钟表盘
            Graphics ng = this.CreateGraphics();

            ng.TranslateTransform(center.X, center.Y);
            for (int i = 0; i < 60; ++i)
            {
                if (i % 5 == 0)
                {
                    ng.FillRectangle(new SolidBrush(Color.Gray), -1, 2 - rad, 2, rad / 15);
                }
                else
                {
                    ng.FillRectangle(new SolidBrush(Color.Gray), 0, 2 - rad, 1, rad / 18);
                }
                ng.RotateTransform(6);
            }

            // 显示时钟指针
            g.DrawLine(giveMePen(Color.Red, 1), center, secPoint);
            g.DrawLine(giveMePen(Color.Black, 2), center, minPoint);
            g.DrawLine(giveMePen(Color.Black, 3), center, hourPoint);

            // 显示时区、时间字符串 which: 0(北京时间), 1(世界统一时间)
            if (which)
            {
                int len = rad / 10;
                UTC.SetBounds(center.X - len, center.Y - rad - 2 * len, len, 2 * len);
                UTCDate.SetBounds(center.X + 2 * rad, center.Y - rad / 3, rad, 2 * rad);
                UTCDate.Text = hour.ToString().PadLeft(2, '0') + ":" + minu.ToString().PadLeft(2, '0') + ":" + sec.ToString().PadLeft(2, '0');
                UTCDate.Font = new Font("隶书", rad / 2, FontStyle.Regular);
            }
            else
            {
                int len = rad / 10;
                BeiJing.SetBounds(center.X - 3 * len, center.Y - rad - 2 * len, len, 2 * len);
                BJDate.SetBounds(center.X + 2 * rad, center.Y - rad / 3, rad, 2 * rad);
                BJDate.Text = hour.ToString().PadLeft(2, '0') + ":" + minu.ToString().PadLeft(2, '0') + ":" + sec.ToString().PadLeft(2, '0');
                BJDate.Font = new Font("隶书", rad / 2, FontStyle.Regular);
            }
        }
Exemple #8
0
 /// <summary>
 /// 地图保存
 /// </summary>
 private void MapSave()
 {
     if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\setting.ini"))
     {
         IniFile.WriteIniData("AGV", "MapSise", Map_Size.Text, AppDomain.CurrentDomain.BaseDirectory + "\\setting.ini");
     }
     if (mapMessage.UpdateSettingMap(UTC.ConvertDateTimeLong(Convert.ToDateTime(MapList.SelectedValue.ToString())), 1))
     {
         MessageBox.Show("设置保存成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
         this.Close();
     }
 }
Exemple #9
0
 private void RouteSave_Click(object sender, RoutedEventArgs e)
 {
     if (ProgramNum.Text.Trim() != "" && RouteName.Text.Trim() != "" && FormatVerification.IsFloat(ProgramNum.Text.Trim()))
     {
         if (mapService.ExistsSystem(ProgramNum.Text.Trim(), UTCTime, RouteData.CreateTime))
         {
             MessageBox.Show("线路号已存在!", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         else if (routes.Count == 0)
         {
             MessageBox.Show("请添加线路!", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         else
         {
             var route = new Route()
             {
                 Name          = RouteName.Text,
                 Program       = Convert.ToInt32(ProgramNum.Text.Trim()),
                 CreateTime    = edit == true ? RouteData.CreateTime : UTC.ConvertDateTimeLong(DateTime.Now),
                 Pbs           = string.Join(",", routes.Select(p => MainInfo.agvPbs.ToList().IndexOf(p.Pbs))),
                 Hook          = string.Join(",", routes.Select(p => MainInfo.agvHook.ToList().IndexOf(p.Hook))),
                 Turn          = string.Join(",", routes.Select(p => MainInfo.agvTurn.ToList().IndexOf(p.Turn))),
                 Direction     = string.Join(",", routes.Select(p => MainInfo.agvDire.ToList().IndexOf(p.Direction))),
                 Speed         = string.Join(",", routes.Select(p => MainInfo.agvSpeed.ToList().IndexOf(p.Speed))),
                 Stop          = string.Join(",", routes.Select(p => p.Stop)),
                 Tag           = string.Join(",", routes.Select(p => p.Tag)),
                 ChangeProgram = string.Join(",", routes.Select(p => p.ChangeProgram)),
             };
             if (mapService.SaveRouteSystem(route, edit, UTC.ConvertDateTimeLong(Convert.ToDateTime(MapMenu.SelectedValue.ToString()))))
             {
                 edit = true;
                 Task.Factory.StartNew(() =>
                 {
                     GetRoutes = mapService.GetrouteList(UTCTime.ToString());
                     this.Dispatcher.Invoke(() => { Line.ItemsSource = GetRoutes; Line.Text = route.Name; });
                 });
                 MessageBox.Show("保存成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
             }
             else
             {
                 MessageBox.Show("保存失败!", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
     }
     else
     {
         MessageBox.Show("格式输入错误!", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        /// <summary>
        /// 获取全部法规列表
        /// </summary>
        public static int getLawResponse()
        {
            string laws = HttpWorker.HttpGet(Global.AllBooksApi, "beginTime=" + UTC.ConvertDateTimeInt(new DateTime(2010, 01, 01)).ToString() + "&pageSize=-1");

            if (laws == "error")
            {
                return(-1);
            }
            AllBooksResponse allBookResponse = TranslationWorker.ConvertStringToEntity <AllBooksResponse>(laws);
            int autoUpdateCount = 0;

            db.refreshLaw(allBookResponse.ConvertToLaws(), out autoUpdateCount);
            return(autoUpdateCount);
        }
Exemple #11
0
        public void LoadMap(Ga_Map GetMap)
        {
            UTCTime = UTC.ConvertDateTimeLong(Convert.ToDateTime(GetMap.CreateTime));
            Tags    = mapService.TagManagement(UTCTime);
            SerialPortData.AutoGenerateColumns = false;
            SerialPortData.ItemsSource         = Tags;
            CanvasWidth  = GetMap.Width * 10;
            CanvasHeight = GetMap.Height * 10;
            double CanvasWidths  = GetMap.Width * 10 * map.MapSise;
            double CanvasHeights = GetMap.Height * 10 * map.MapSise;

            map.Initial_Canvas(TopX, TopY, mainPanel, CanvasWidths, CanvasHeights);
            map.LoadEditMap(UTCTime, false, true);
        }
Exemple #12
0
        public void LoadMap(Ga_Map GetMap)
        {
            CanvasWidth  = GetMap.Width * 10;
            CanvasHeight = GetMap.Height * 10;
            double CanvasWidths  = GetMap.Width * 10 * map.MapSise;
            double CanvasHeights = GetMap.Height * 10 * map.MapSise;

            map.Initial_Canvas(TopX, TopY, mainPanel, CanvasWidths, CanvasHeights);
            UTCTime = UTC.ConvertDateTimeLong(Convert.ToDateTime(GetMap.CreateTime));
            map.LoadEditMap(UTCTime, false, true);
            map.valuePairs.Select(p => p.Value).ToList().ForEach(p => { p.MouseDown += Value_MouseDown; p.Cursor = Cursors.Hand; });
            GetRoutes          = mapService.GetrouteList(UTCTime.ToString());
            Line.ItemsSource   = GetRoutes;
            Line.SelectedIndex = 0;
        }
Exemple #13
0
        public List <Comment> ConverToComments()
        {
            List <Comment> comments = new List <Comment>();

            foreach (opinionItem opinion in this.data.list)
            {
                Comment comment = new Comment();
                comment.Id              = opinion.id.ToString();
                comment.lawId           = opinion.bookId;
                comment.nodeId          = opinion.nodeId.ToString();
                comment.userId          = opinion.readerId;
                comment.comment_date    = UTC.ConvertIntDatetime(opinion.createTime).ToString("yyyy-MM-dd HH:mm:ss");
                comment.comment_content = opinion.msg;
                comments.Add(comment);
            }
            return(comments);
        }
Exemple #14
0
 /// <summary>
 /// 删除地图
 /// </summary>
 /// <param name="gs"></param>
 /// <returns></returns>
 public bool Delete_Map(List <Ga_Map> gs)
 {
     try
     {
         foreach (Ga_Map item in gs)
         {
             long UTCTime = UTC.ConvertDateTimeLong(Convert.ToDateTime(item.CreateTime));
             IO_AGVMapService.RemoveMap(UTCTime);
             CachePlant.Remove(UTCTime.ToString()); //移除缓存
         }
         return(true);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #15
0
        /// <summary>
        /// 添加AGV
        /// </summary>
        /// <param name="agv"></param>
        /// <returns></returns>
        public bool Addagv(Ga_agv agv)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("INSERT INTO `ga_agv`.`ga_agv`(`agvNum`, `agvSerialNum`, `agvName`, `agvIp`, `agvPort`, `agvCreateTime`, `agvOffLineTime`, `agvOnLineTime`, `agvFirmware`) VALUES ( @agvNum,@agvSerialNum, @agvName, @agvIp, @agvPort, @agvCreateTime, @agvOffLineTime, @agvOnLineTime,@agvFirmware)");
            MySqlParameter[] par =
            {
                new MySqlParameter("@agvNum",         MySqlDbType.Int32, 10000)
                {
                    Value = agv.agvNum
                },
                new MySqlParameter("@agvSerialNum",   MySqlDbType.VarChar, 10000)
                {
                    Value = agv.agvSerialNum
                },
                new MySqlParameter("@agvName",        MySqlDbType.VarChar, 10000)
                {
                    Value = agv.agvName
                },
                new MySqlParameter("@agvIp",          MySqlDbType.VarChar, 10000)
                {
                    Value = agv.agvIp
                },
                new MySqlParameter("@agvPort",        MySqlDbType.Int32, 10000)
                {
                    Value = agv.agvPort
                },
                new MySqlParameter("@agvCreateTime",  MySqlDbType.Int32, 10000)
                {
                    Value = UTC.ConvertDateTimeLong(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")))
                },
                new MySqlParameter("@agvOffLineTime", MySqlDbType.VarChar, 10000)
                {
                    Value = agv.agvOffLineTime
                },
                new MySqlParameter("@agvOnLineTime",  MySqlDbType.VarChar, 10000)
                {
                    Value = agv.agvOnLineTime
                },
                new MySqlParameter("@agvFirmware",    MySqlDbType.VarChar, 10000)
                {
                    Value = agv.agvFirmware
                },
            };
            return(MySqlHelper.ExecuteNonQuery(sql.ToString(), par) > 0 ? true : false);
        }
Exemple #16
0
        /// <summary>
        /// 保存地图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveMap_Click(object sender, RoutedEventArgs e)
        {
            string UTCTime = UTC.ConvertDateTimeLong(Convert.ToDateTime(GetMap.CreateTime)).ToString();

            if (instrument.MapPreserve(UTCTime, !editStatic, GetMap.Name, CanvasWidth, CanvasHeight))
            {
                if (!editStatic)
                {
                    editStatic = true;
                }

                CachePlant.Remove(UTCTime); //移除缓存
                MessageBox.Show("保存成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                MessageBox.Show("保存失败", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #17
0
        /// <summary>
        /// 加载所有地图数据
        /// </summary>
        /// <returns></returns>
        public ObservableCollection <Ga_Map> GetMapRegulate()
        {
            ObservableCollection <Ga_Map> ga_s = new ObservableCollection <Ga_Map>();
            MySqlDataReader mySql = IO_AGVMapService.MapArray();

            while (mySql.Read())
            {
                ga_s.Add(new Ga_Map()
                {
                    Name       = mySql["Name"].ToString(),
                    Width      = Convert.ToDouble(mySql["Width"].ToString()),
                    Height     = Convert.ToDouble(mySql["Height"].ToString()),
                    ID         = Convert.ToInt32(mySql["ID"].ToString()),
                    CreateTime = UTC.ConvertLongDateTime(long.Parse(mySql["CreateTime"].ToString())).ToString("yyyy-MM-dd HH:mm:ss")
                });
            }
            mySql.Close();
            return(ga_s);
        }
Exemple #18
0
        /// <summary>
        /// 载入数据
        /// </summary>
        public void LoadMap(bool edit)
        {
            this.Title   = "地图编辑-" + GetMap.Name;
            CanvasWidth  = GetMap.Width * 10;
            CanvasHeight = GetMap.Height * 10;
            double CanvasWidths  = CanvasWidth * instrument.MapSise;
            double CanvasHeights = CanvasHeight * instrument.MapSise;

            instrument.action     = EditTag;
            instrument.AreaAction = EditArea;
            instrument.Initial_Canvas(TopX, TopY, mainPanel, CanvasWidths, CanvasHeights);
            if (edit)
            {
                instrument.LoadEditMap(UTC.ConvertDateTimeLong(Convert.ToDateTime(GetMap.CreateTime)), CanvasWidth, CanvasHeight, true);
            }
            else
            {
                instrument.Canvas_Draw();
            }
        }
Exemple #19
0
 /// <summary>
 /// 显示具体地图信息
 /// </summary>
 private void MapShow()
 {
     MapInstrument.keyValuePairs.Clear();
     MapInstrument.valuePairs.Clear();
     MapInstrument.wirePointArrays.Clear();
     MapInstrument.GetKeyValues.Clear();
     Painting.siseWin = 1;
     MapIN.Children.Clear();
     string[] arr = ((DataRowView)MapData.SelectedValue).Row.ItemArray[1].ToString().Split(',');
     if (arr.Count().Equals(3))
     {
         string Times  = arr[0];
         string MpName = ((DataRowView)MapData.SelectedValue).Row.ItemArray[0].ToString();
         MapName.Content = "地图区域信息(" + MpName + ")";
         MapNa           = MpName;
         MapIN.Width     = double.Parse(arr[1]) * MapManag.Sise;
         MapIN.Height    = double.Parse(arr[2]) * MapManag.Sise;
         MapTime         = long.Parse(UTC.ConvertDateTimeLong(Convert.ToDateTime(Times)).ToString());
         MapManag.SelectMap(UTC.ConvertDateTimeLong(Convert.ToDateTime(Times)), MapIN, false);
     }
 }
Exemple #20
0
        /// <summary>
        /// 查询所有地图
        /// </summary>
        public void MapDataBinding(string MpName)
        {
            MapInstrument.keyValuePairs.Clear();
            MapInstrument.valuePairs.Clear();
            MapInstrument.wirePointArrays.Clear();
            MapInstrument.GetKeyValues.Clear();

            Thread thread = new Thread(() =>
            {
                DataTable dt = new DataTable("Map");
                dt.Columns.Add(new DataColumn("MapName"));
                dt.Columns.Add(new DataColumn("MapInfo"));
                DataTable ga = GesMap.GetMapData(MpName);
                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    if (ga != null)
                    {
                        foreach (DataRow item in ga.Rows)
                        {
                            dt.Rows.Add(new object[] { item["Name"].ToString(), (UTC.ConvertLongDateTime(long.Parse(item["CreateTime"].ToString())).ToString() + "," + item["Width"].ToString() + "," + item["Height"].ToString()) });
                        }

                        MapData.ItemsSource         = dt.DefaultView;
                        MapData.AutoGenerateColumns = false;
                        MapData.SelectedIndex       = 0;
                        if (ga.Rows.Count > 0)
                        {
                            MapShow();
                        }
                    }
                }));
            });

            thread.IsBackground = true;
            thread.Start();
        }
Exemple #21
0
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SubmitPro_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(ProgramNO.Text) || string.IsNullOrEmpty(Convert.ToString(ProgramName.Text)))
            {
                MessageBox.Show("请输入线路名称及Program号");
                return;
            }
            if (!IsFloat(ProgramNO.Text.Trim()))
            {
                MessageBox.Show("Program号只能为数字");
                return;
            }
            else if (EditlineData.Items.Count == 0)
            {
                MessageBox.Show("未编辑线路");
                return;
            }
            StringBuilder sbTag       = new StringBuilder();
            StringBuilder sbSpeed     = new StringBuilder();
            StringBuilder sbStop      = new StringBuilder();
            StringBuilder sbTurn      = new StringBuilder();
            StringBuilder sbDirection = new StringBuilder();
            StringBuilder sbPbs       = new StringBuilder();
            StringBuilder sbHook      = new StringBuilder();
            StringBuilder sbProgram   = new StringBuilder();

            for (int i = 0; i < EditlineData.Items.Count; i++)
            {
                sbTag.Append(((DataRowView)EditlineData.Items[i])[0]);
                sbTag.Append(",");
                sbSpeed.Append(tag.agvSpeedIndex(((DataRowView)EditlineData.Items[i])[1].ToString()));
                sbSpeed.Append(",");
                sbStop.Append(((DataRowView)EditlineData.Items[i])[6]);
                sbStop.Append(",");
                sbTurn.Append(tag.agvTurnIndex(((DataRowView)EditlineData.Items[i])[3].ToString()));
                sbTurn.Append(",");
                sbDirection.Append(tag.agvDireIndex(((DataRowView)EditlineData.Items[i])[4].ToString()));
                sbDirection.Append(",");
                sbPbs.Append(tag.agvPbsIndex(((DataRowView)EditlineData.Items[i])[2].ToString()));
                sbPbs.Append(",");
                sbHook.Append(tag.agvHookIndex(((DataRowView)EditlineData.Items[i])[5].ToString()));
                sbHook.Append(",");
                sbProgram.Append(((DataRowView)EditlineData.Items[i])[7]);
                sbProgram.Append(",");
            }

            sbTag.Remove(sbTag.Length - 1, 1);
            sbSpeed.Remove(sbSpeed.Length - 1, 1);
            sbStop.Remove(sbStop.Length - 1, 1);
            sbTurn.Remove(sbTurn.Length - 1, 1);
            sbDirection.Remove(sbDirection.Length - 1, 1);
            sbPbs.Remove(sbPbs.Length - 1, 1);
            sbHook.Remove(sbHook.Length - 1, 1);
            sbProgram.Remove(sbProgram.Length - 1, 1);

            string tagStr     = sbTag.ToString();
            string speedStr   = sbSpeed.ToString();
            string stopStr    = sbStop.ToString();
            string turnStr    = sbTurn.ToString();
            string direStr    = sbDirection.ToString();
            string pbsStr     = sbPbs.ToString();
            string hookStr    = sbHook.ToString();
            string programStr = sbProgram.ToString();

            string agvStr = "";//地图上不用注册agv,为保证程序正常运行保留字段。

            if (edid.Equals(0))
            {
                if (messageBLL.Program(ProgramNO.Text.Trim(), Times))
                {
                    MessageBox.Show("Program已存在,请重新输入Program");
                    return;
                }
                else
                {
                    if (messageBLL.InsertRouteMap(ProgramNO.Text.Trim(), ProgramName.Text.Trim(), UTC.ConvertDateTimeLong(DateTime.Now), Times, tagStr, speedStr, stopStr, turnStr, direStr, pbsStr, hookStr, agvStr, programStr))
                    {
                        MessageBox.Show("保存成功");
                        Maplist_SelectionChanged(null, null);
                    }
                    else
                    {
                        MessageBox.Show("保存失败");
                    }
                }
            }
            else if (edid.Equals(1))
            {
                if (messageBLL.UpdateRouteMap(Times, Convert.ToInt32(ProgramNO.Text.Trim()), ProgramName.Text.Trim(), tagStr, speedStr, stopStr, turnStr, direStr, pbsStr, hookStr, agvStr, programStr))
                {
                    MessageBox.Show("保存成功");
                    Maplist_SelectionChanged(null, null);
                }
                else
                {
                    MessageBox.Show("保存失败");
                }
            }
        }
Exemple #22
0
        public override void Read()
        {
            base.Read();
            this.Sender   = reader.ReadUInt32();
            this.Sequence = reader.ReadUInt32();
            uint time = reader.ReadUInt32();

            this.Time  = UTC.UnixTimestampToDate(time);
            this.Class = (ClassMessage)reader.ReadUInt32();
            uint offsetPlain      = reader.ReadUInt32();
            uint offsetAttributes = reader.ReadUInt32();

            long currentPos = this.reader.BaseStream.Position - 8;

            List <byte> message = new List <byte>();
            byte        tmp;

            if (currentPos != offsetPlain)
            {
                while ((tmp = reader.ReadByte()) != 0)
                {
                    message.Add(tmp);
                }
                this.HtmlMessage = UTF8Encoding.UTF8.GetString(message.ToArray());
            }

            message.Clear();
            while ((tmp = reader.ReadByte()) != 0)
            {
                message.Add(tmp);
            }
            this.PlainMessage = Encoding.GetEncoding(1250).GetString(message.ToArray());

            message.Clear();

            while (reader.PeekChar() != -1)
            {
                byte attributeType = this.reader.ReadByte(); //0x02 -> attr

                if (attributeType == 0x01)
                {
                    uint count = this.reader.ReadUInt32();
                    for (uint i = 0; i < count; ++i)
                    {
                        this.recipients.Add(this.reader.ReadUInt32());
                    }
                }
                else if (attributeType == 0x02)
                {
                    ushort length = this.reader.ReadUInt16(); // length
                    long   range  = this.reader.BaseStream.Position + length;
                    while (this.reader.BaseStream.Position < range)
                    {
                        ushort         position = reader.ReadUInt16();
                        FormatType     type     = (FormatType)reader.ReadByte();
                        RichTextFormat block    = new RichTextFormat(position, type);

                        if (type.HasFlag(FormatType.FontColor))
                        {
                            block.Color = Color.FromArgb(reader.ReadByte(),
                                                         reader.ReadByte(), reader.ReadByte());
                        }

                        if (type.HasFlag(FormatType.Image))
                        {
                            RichTextImage image = new RichTextImage();
                            image.Size  = this.reader.ReadUInt32();
                            image.CRC32 = this.reader.ReadUInt32();
                            block.Image = image;
                        }
                        this.attributes.Add(block);
                    }
                }
            }
            this.HtmlMessage = RTF.PlainToHtml(this.PlainMessage, this.Attributes);
        }
Exemple #23
0
        static void Main(string[] args)
        {
            DateTime UTC;

            PlanetEphemeris[] ephemerides;

            //Load Data From Disk
            string         Path  = @"D:\VSOP2013DATA";
            DataReader     dr    = new DataReader(Path);
            VSOPCalculator v2013 = new VSOPCalculator(dr.ReadData());

            Console.WriteLine("Planet Data Load OK...");


            Console.WriteLine("Parse UTC string that conforms to ISO 8601:  2018-08-18T07:22:16.0000000Z");
            //Parse Time
            while (true)
            {
                Console.Write("Input Time As UTC:");
                //string inputT = Console.ReadLine();
                string         inputT  = "2000-01-01T12:00:00.0000000Z";
                CultureInfo    culture = CultureInfo.CreateSpecificCulture("en-US");
                DateTimeStyles style   = DateTimeStyles.AdjustToUniversal;
                if (DateTime.TryParse(inputT, culture, style, out UTC))
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Invalid Entry...");
                }
            }

            //Convert UTC to TDB (Barycentric Dynamical Time)
            DateTime TDB = TimeConverter.UTCtoTDB(UTC);

            Console.WriteLine();

            Console.WriteLine("Press Enter To Start Substitution...");
            Console.ReadLine();


            #region
            //Calculate specific planet. Earth=2
            PlanetEphemeris r = v2013.CalcIP((int)Body.EMB, UTC);
            Console.WriteLine("===============================================================");
            Console.WriteLine("{0} at {1}", Enum.GetName(typeof(Body), 2), UTC.ToString());
            Console.WriteLine();
            Console.WriteLine("            Elliptic Elements - Dynamical Frame J2000");
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "semi-major axis (au)", r.DynamicalELL[0]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "mean longitude (rd)", r.DynamicalELL[1]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "k = e*cos(pi) (rd)", r.DynamicalELL[2]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "h = e*sin(pi) (rd)", r.DynamicalELL[3]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "q = sin(i/2)*cos(omega) (rd)", r.DynamicalELL[4]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "p = sin(i/2)*sin(omega) (rd)", r.DynamicalELL[5]));
            Console.WriteLine();
            Console.WriteLine("            Ecliptic Heliocentric Coordinates - Dynamical Frame J2000");
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Positions  X (au)", r.DynamicalXYZ[0]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Positions  Y (au)", r.DynamicalXYZ[1]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Positions  Z (au)", r.DynamicalXYZ[2]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Velocities X'(au/d)", r.DynamicalXYZ[3]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Velocities Y'(au/d)", r.DynamicalXYZ[4]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Velocities Z'(au/d)", r.DynamicalXYZ[5]));
            Console.WriteLine();
            Console.WriteLine("            Equatorial Heliocentric Coordinates - ICRS Frame J2000");
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Positions  X (au)", r.ICRSXYZ[0]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Positions  Y (au)", r.ICRSXYZ[1]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Positions  Z (au)", r.ICRSXYZ[2]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Velocities X'(au/d)", r.ICRSXYZ[3]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Velocities Y'(au/d)", r.ICRSXYZ[4]));
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Velocities Z'(au/d)", r.ICRSXYZ[5]));
            Console.WriteLine("===============================================================");
            ////
            #endregion

            //Calculate Each Variable
            double R = v2013.CalcIV(2, 0, TDB);
            Console.WriteLine("===============================================================");
            Console.WriteLine(Enum.GetName(typeof(Body), 2) + " at " + UTC.ToString());
            Console.WriteLine();
            Console.WriteLine("            Elliptic Elements - Dynamical Frame J2000");
            Console.WriteLine(String.Format("{0,-30} : {1,-30}", "semi-major axis (au)", R));
            Console.WriteLine("===============================================================");
            ////

            //Calculate All Planet
            ephemerides = v2013.CalcAll(TDB);
            PrintResult(ephemerides, TDB);
            Console.ReadLine();
            ////
        }