/// <summary>
 /// 更新里程信息按钮事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnUpdateMileInfo_Click(object sender, EventArgs e)
 {
     if (waveformMaker.WaveformDataList[0].MileageFix.FixData == null || waveformMaker.WaveformDataList[0].MileageFix.FixData.Count == 0)
     {
         MessageBox.Show("没有进行里程校正,不需要更新里程!");
         return;
     }
     if (waveformMaker.WaveformDataList[0].InvalidDataList.Count == 0)
     {
         return;
     }
     try
     {
         for (int i = 0; i < waveformMaker.WaveformDataList[0].InvalidDataList.Count; i++)
         {
             InvalidData data       = waveformMaker.WaveformDataList[0].InvalidDataList[i];
             float       iStartMile = waveformMaker.WaveformDataList[0].MileageFix.CalcPointMileStone(long.Parse(data.sStartPoint));
             float       iEndMile   = waveformMaker.WaveformDataList[0].MileageFix.CalcPointMileStone(long.Parse(data.sEndPoint));
             invalidManager.InvalidDataUpdate(idfFilePath, data.sStartPoint,
                                              data.sEndPoint, (iStartMile / 1000f).ToString(), (iEndMile / 1000f).ToString());
         }
     }
     catch (Exception ex)
     {
         MyLogger.LogError("更新无效数据时失败", ex);
     }
     MessageBox.Show("更新成功!");
     GetInvalidData();
 }
Beispiel #2
0
        public void Adjust_InvalidRawData_RaiseEvent()
        {
            var data = new InvalidData();

            adjuster.OnFoundInvalidData = d => { data = d; };
            buildRepositoryFake.Source  = "a";
            buildRepositoryFake.RawData = "{}";

            adjuster.Adjust();

            Assert.That(data.Data, Is.EqualTo("{}"));
            Assert.That(data.Source, Is.EqualTo("a"));
        }
Beispiel #3
0
        /// <summary>
        ///idf数据库操作:查询--InvalidData表格
        /// </summary>
        /// <param name="idfFile"></param>
        /// <returns></returns>
        public List <InvalidData> InvalidDataList(string idfFile)
        {
            List <InvalidData> listIDC = new List <InvalidData>();

            try
            {
                using (OleDbConnection sqlconn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + idfFile + ";Persist Security Info=True"))
                {
                    string       sSql   = "select * from InvalidData order by clng(StartPoint)";
                    OleDbCommand sqlcom = new OleDbCommand(sSql, sqlconn);
                    sqlconn.Open();
                    OleDbDataReader oleDBr    = sqlcom.ExecuteReader();
                    int             columnNum = oleDBr.FieldCount;
                    while (oleDBr.Read())
                    {
                        InvalidData idc = new InvalidData();
                        idc.iId         = int.Parse(oleDBr.GetValue(0).ToString());
                        idc.sStartPoint = oleDBr.GetValue(1).ToString();
                        idc.sEndPoint   = oleDBr.GetValue(2).ToString();
                        idc.sStartMile  = oleDBr.GetValue(3).ToString();
                        idc.sEndMile    = oleDBr.GetValue(4).ToString();
                        idc.iType       = int.Parse(oleDBr.GetValue(5).ToString());
                        idc.sMemoText   = oleDBr.GetValue(6).ToString();
                        idc.iIsShow     = int.Parse(oleDBr.GetValue(7).ToString());
                        if (columnNum == 9)
                        {
                            idc.ChannelType = oleDBr.GetValue(8).ToString();
                        }
                        else
                        {
                            idc.ChannelType = "";
                        }

                        listIDC.Add(idc);
                    }
                    oleDBr.Close();
                    sqlconn.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("无效区段读取异常:" + ex.Message);
            }
            return(listIDC);
        }
Beispiel #4
0
 private void Dtm_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
 {
     if (dataType == DataType.Uri)
     {
         try
         {
             args.Request.Data.Properties.Title = "Native Share URI";
             args.Request.Data.SetWebLink(new Uri(data));
         }
         catch (UriFormatException)
         {
             InvalidData?.Invoke(this, null);
         }
     }
     else if (dataType == DataType.Text)
     {
         args.Request.Data.Properties.Title = "Native Share Text";
         args.Request.Data.SetText(data);
     }
 }
Beispiel #5
0
        private void OnClientDataRecevied(object sender, Data e)
        {
            var c = (Client)sender;

            Console.WriteLine(c.User.UserName + "@" + c.Id + ": " + e.Command.ToString() + ": " + e.Content);
            switch (e.Command)
            {
            case Command.Status:
                c.Send(new Data(Command.Message, "Client #" + c.Id + ", Logged as" + c.User.UserName + ", Can Send: " + c.User.CanSend + ", Can Code: " + c.User.CanCode, "root"));
                return;

            case Command.SendMsg:
                if (c.User.CanSend)
                {
                    if (c.User.CanCode && e.Content.StartsWith("sh: "))
                    {
                        RunCode(e.Content.Substring(4), c);
                    }
                    else
                    {
                        foreach (var client in Clients)
                        {
                            client.Send(new Data(Command.Message, e.Content, c.User.UserName));
                        }
                    }
                }
                else
                {
                    c.Send(new Data(Command.Message, "Dear " + c.User.UserName + ", You can't send any message because you are limited.", "root"));
                    foreach (var client in Clients.Where(a => a.User.CanCode))
                    {
                        client.Send(new Data(Command.Message, c.User.UserName + " says:\r\n\t" + e.Content, "Limited users"));
                    }
                }
                return;

            case Command.Disconnect:
                c.Disconnect();
                return;

            case Command.Login:
                if (c.User.UserName == "anonymous")
                {
                    foreach (var u in Users)
                    {
                        if (e.Content == u.UserName + ":" + u.Password)
                        {
                            c.User = u;
                            SendToAllAsRoot("#" + c.Id + " logged in as " + u.UserName);
                            return;
                        }
                    }
                    c.Send(new Data(Command.Message, "Bad User Name/Password", "root"));
                    SendToAllAsRoot("An attempt to login from #" + c.Id);
                }
                else
                {
                    c.Send(new Data(Command.Message, "You've logged in already.", "root"));
                }
                return;

            case Command.Message:
                foreach (var cl in Clients.Where(a => a.User.UserName == Users[1].UserName))
                {
                    cl.Send(new Data(Command.Message, "Message: " + e.Content, "root - Msg from Client #" + c.Id));
                }
                break;

            default:
                InvalidData?.Invoke(c, e);
                return;
            }
        }
Beispiel #6
0
        public static void Main(string[] args)
        {
            InvalidData invalidDataTest = new InvalidData();

            invalidDataTest.runAll();
        }
Beispiel #7
0
 /// <summary>
 /// Fires the InvalidData event.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="message">The message.</param>
 protected void FireWarning(string propertyName, string message)
 {
     // TODO - Add to log
     InvalidData?.Invoke(this, new InvalidDataEventArgs(propertyName, message));
 }
Beispiel #8
0
        public ActionResult ImportMachine(int type)
        {
            var result = new ImportUploadResult()
            {
                IsSuccess = false
            };
            var                invalidlist = new List <InvalidData>();
            StringBuilder      strbuild    = new StringBuilder();
            string             FileName;
            string             savePath;
            HttpPostedFileBase file = Request.Files["file"];

            if (file == null || file.ContentLength <= 0)
            {
                result.Message = "please choose file";
                return(Content(JsonHelper.JsonSerializer(result)));
            }
            else
            {
                string fileName   = Path.GetFileName(file.FileName);
                int    filesize   = file.ContentLength;                         //获取上传文件的大小单位为字节byte
                string fileEx     = Path.GetExtension(fileName);                //获取上传文件的扩展名
                string NoFileName = Path.GetFileNameWithoutExtension(fileName); //获取无扩展名的文件名
                int    Maxsize    = 4000 * 1024;                                //定义上传文件的最大空间大小为4M
                string FileType   = ".xls,.xlsx";                               //定义上传文件的类型字符串

                FileName = NoFileName + fileEx;
                if (!FileType.Contains(fileEx))
                {
                    result.Message = "please upload .xls and .xlsx";
                    return(Content(JsonHelper.JsonSerializer(result)));
                }
                if (filesize >= Maxsize)
                {
                    result.Message = string.Format("file size can't big than {0}", Maxsize);
                    return(Content(JsonHelper.JsonSerializer(result)));
                }
                string path = Server.MapPath("~/App_Data/uploads");
                savePath = Path.Combine(path, FileName);
                file.SaveAs(savePath);
            }

            string strConn;

            strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + savePath + ";Extended Properties=Excel 12.0;";
            using (OleDbConnection conn = new OleDbConnection(strConn))
            {
                conn.Open();
                OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Sheet1$]", strConn);
                DataSet          myDataSet = new DataSet();
                try
                {
                    myCommand.Fill(myDataSet, "ExcelInfo");
                }
                catch (Exception ex)
                {
                    result.Message = ex.Message;
                    return(Content(JsonHelper.JsonSerializer(result)));
                }
                DataTable table = myDataSet.Tables["ExcelInfo"].DefaultView.ToTable();

                try
                {
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        var datevalid1 = false;
                        var datevalid2 = false;
                        var invalid    = new InvalidData();
                        if (!string.IsNullOrEmpty(table.Rows[i][6].ToString()))
                        {
                            datevalid1 = DataConvertHelper.IsDateTime(table.Rows[i][6].ToString());
                            if (!datevalid1)
                            {
                                invalid.Key    = table.Rows[i][2].ToString();
                                invalid.Value1 = table.Rows[i][6].ToString();
                            }
                        }
                        if (!string.IsNullOrEmpty(table.Rows[i][12].ToString()))
                        {
                            datevalid2 = DataConvertHelper.IsDateTime(table.Rows[i][12].ToString());
                            if (!datevalid2)
                            {
                                invalid.Key    = table.Rows[i][2].ToString();
                                invalid.Value2 = table.Rows[i][12].ToString();
                            }
                        }
                        if (!datevalid1 && !datevalid2)
                        {
                            invalidlist.Add(invalid);
                            continue;
                        }
                        var model = new MaToolModel();
                        model.BMClassification   = type;
                        model.BMEquipmentName    = table.Rows[i][0].ToString();
                        model.BMEquipmentNo      = table.Rows[i][1].ToString();
                        model.BMFixtureNo        = table.Rows[i][2].ToString();
                        model.BMType             = table.Rows[i][3].ToString();
                        model.BMSerialNumber     = table.Rows[i][4].ToString();
                        model.BMQuantity         = DataConvertHelper.ToInt(table.Rows[i][5].ToString(), 0);
                        model.BMManufacturedDate = table.Rows[i][6].ToString();
                        model.BMPower            = table.Rows[i][7].ToString();
                        model.BMOutlineDimension = table.Rows[i][8].ToString();
                        model.BMAbility          = table.Rows[i][9].ToString();
                        model.BMNeedPressureAir  = DataConvertHelper.GetYesOrNoValue(table.Rows[i][10].ToString());
                        model.BMNeedCoolingWater = DataConvertHelper.GetYesOrNoValue(table.Rows[i][11].ToString());
                        model.BMIncomingDate     = table.Rows[i][12].ToString();
                        model.BMRemarks          = table.Rows[i][13].ToString();
                        var inserResult = MaterialBusiness.SaveMaTool(model, LoginUser);

                        //if (type != 4)
                        //{
                        //    MachineTool(type, table, i);
                        //}
                        //else {
                        //    MaterialTool(type, table, i);
                        //}
                    }
                    result.invalidData = invalidlist;
                    result.IsSuccess   = true;
                }
                catch (Exception ex)
                {
                    result.Message = ex.Message;
                    return(Content(JsonHelper.JsonSerializer(result)));
                }
                conn.Close();
            }
            return(Content(JsonHelper.JsonSerializer(result)));
        }