public static Model.GDCoorSysXYZ GetModel(string YSZBXM, string MDZBXM) { string strSql = "select * from GDCoorSysXYZ where YSZBXM='" + YSZBXM + "' and MDZBXM='" + MDZBXM + "'"; Model.GDCoorSysXYZ model = new Model.GDCoorSysXYZ(); DataSet ds = DBHelperSQL.GetDataSet(strSql, connectionString); if (ds.Tables[0].Rows.Count != 0) { model.ID = Convert.ToInt32(ds.Tables[0].Rows[0]["ID"]); model.X = Convert.ToDouble(AES.AESDecrypt(ds.Tables[0].Rows[0]["X"].ToString())); model.Y = Convert.ToDouble(AES.AESDecrypt(ds.Tables[0].Rows[0]["Y"].ToString())); model.Z = Convert.ToDouble(AES.AESDecrypt(ds.Tables[0].Rows[0]["Z"].ToString())); model.aa = Convert.ToDouble(AES.AESDecrypt(ds.Tables[0].Rows[0]["aa"].ToString())); model.bb = Convert.ToDouble(AES.AESDecrypt(ds.Tables[0].Rows[0]["bb"].ToString())); model.cc = Convert.ToDouble(AES.AESDecrypt(ds.Tables[0].Rows[0]["cc"].ToString())); model.YSZBXM = Convert.ToString(ds.Tables[0].Rows[0]["YSZBXM"].ToString()); model.MDZBXM = Convert.ToString(ds.Tables[0].Rows[0]["MDZBXM"].ToString()); model.X = model.X - 3242.23; model.Y = model.Y + 23423.2; model.Z = model.Z + 34.3; model.aa -= 12.324; model.bb -= 6.654; model.cc -= 1.545; return(model); } else { return(null); } }
public static bool Update(Model.GDCoorSysXYZ model) { model.X = model.X + 3242.23; model.Y = model.Y - 23423.2; model.Z = model.Z - 34.3; model.aa += 12.324; model.bb += 6.654; model.cc += 1.545; string strSql = "update GDCoorSysXYZ set X=@X, Y=@Y, Z=@Z,aa=@aa,bb=@bb,cc=@cc,YSZBXM=@YSZBXM,MDZBXM=@MDZBXM where ID = " + model.ID.ToString(); SqlParameter X = new SqlParameter("X", SqlDbType.NVarChar); X.Value = AES.AESEncrypt(model.X.ToString()); SqlParameter Y = new SqlParameter("Y", SqlDbType.NVarChar); Y.Value = AES.AESEncrypt(model.Y.ToString()); SqlParameter Z = new SqlParameter("Z", SqlDbType.NVarChar); Z.Value = AES.AESEncrypt(model.Z.ToString()); SqlParameter aa = new SqlParameter("aa", SqlDbType.NVarChar); aa.Value = AES.AESEncrypt(model.aa.ToString()); SqlParameter bb = new SqlParameter("bb", SqlDbType.NVarChar); bb.Value = AES.AESEncrypt(model.bb.ToString()); SqlParameter cc = new SqlParameter("cc", SqlDbType.NVarChar); cc.Value = AES.AESEncrypt(model.cc.ToString()); SqlParameter YSZBXM = new SqlParameter("YSZBXM", SqlDbType.NVarChar); YSZBXM.Value = model.YSZBXM.ToString(); SqlParameter MDZBXM = new SqlParameter("MDZBXM", SqlDbType.NVarChar); MDZBXM.Value = model.MDZBXM.ToString(); return(DBHelperSQL.GetNums(strSql, new SqlParameter[] { X, Y, Z, aa, bb, cc, YSZBXM, MDZBXM }, connectionString) == 1 ? true : false); }
private bool UpdateData() { Model.CoorSysPars mcs = GetModelFromRequest(); if (mcs.YSZBXM == "GD") { result += "过渡坐标系不能修改"; } mcs.ID = Convert.ToInt32(Request["ID"]); if (!ValidateCoorPara(mcs, 1)) { return(false); } DAL.CoorSysPars.Update(mcs); //更改过度坐标系坐标 Model.OCoorSysPars mocsp = DAL.CoorSysPars.GetOModel(mcs.YSZBXM, mcs.MDZBXM); //加入GDCoorSysXYZ Model.GDCoorSysXYZ mgdcs = new Model.GDCoorSysXYZ(); mgdcs.YSZBXM = mocsp.YSZBXM; mgdcs.MDZBXM = mocsp.MDZBXM; Random r = new Random(); mgdcs.X = r.Next(-4, 3) + r.NextDouble(); double xs = (mocsp.X + mgdcs.X) * 10 - Math.Floor(mocsp.X * 10 + mgdcs.X * 10); xs = 1 - xs; mgdcs.X = mgdcs.X + xs / 10; mgdcs.Y = r.Next(2, 5) + r.NextDouble(); xs = (mocsp.Y + mgdcs.Y) * 10 - Math.Floor(mocsp.Y * 10 + mgdcs.Y * 10); xs = 1 - xs; mgdcs.Y += xs / 10; mgdcs.Z = r.Next(1, 4) + r.NextDouble(); xs = (mocsp.Z + mgdcs.Z) * 10 - Math.Floor(mocsp.Z * 10 + mgdcs.Z * 10); xs = 1 - xs; mgdcs.Z += xs / 10; mgdcs.aa = (double)r.Next(1, 9) / 100.0 + (double)r.Next(1, 9) / 1000.0; xs = (mocsp.aa + mgdcs.aa) * 1000 - Math.Floor(mocsp.aa * 1000 + mgdcs.aa * 1000); xs = 1 - xs; mgdcs.aa += xs / 1000; mgdcs.bb = (double)r.Next(1, 9) / 100.0 + (double)r.Next(1, 9) / 1000.0; xs = (mocsp.bb + mgdcs.bb) * 1000 - Math.Floor(mocsp.bb * 1000 + mgdcs.bb * 1000); xs = 1 - xs; mgdcs.bb += xs / 1000; mgdcs.cc = (double)r.Next(1, 9) / 100.0 + (double)r.Next(1, 9) / 1000.0; xs = (mocsp.cc + mgdcs.cc) * 1000 - Math.Floor(mocsp.cc * 1000 + mgdcs.cc * 1000); xs = 1 - xs; mgdcs.cc += xs / 1000; //mgdcs.aa = 0; mgdcs.bb = 0; mgdcs.cc = 0; if (DAL.GDCoorSysXYZ.Exists(mcs.MDZBXM)) { Model.GDCoorSysXYZ oldmgdcs = DAL.GDCoorSysXYZ.GetModel(mgdcs.YSZBXM, mgdcs.MDZBXM); mgdcs.ID = oldmgdcs.ID; bool IsSu = DAL.GDCoorSysXYZ.Update(mgdcs); } else { DAL.GDCoorSysXYZ.Add(mgdcs); } double hudumiao = (180.0 / Math.PI) * 3600; Canshu csk = new Canshu(); csk.dx = mocsp.X; csk.dy = mocsp.Y; csk.dz = mocsp.Z; csk.m0 = mocsp.m / 1000000.0; csk.Qx = mocsp.aa / hudumiao; csk.Qy = mocsp.bb / hudumiao; csk.Qz = mocsp.cc / hudumiao; CoorTrans coortrana = new CoorTrans(); coortrana.SetCanshu(csk); Model.GDCoorSysXYZ mgdc = DAL.GDCoorSysXYZ.GetModel(mcs.YSZBXM, mcs.MDZBXM); coortrana.CalCanshu(mgdc.X, mgdc.Y, mgdc.Z, mgdc.aa / hudumiao, mgdc.bb / hudumiao, mgdc.cc / hudumiao); Model.CoorSysPars gd = new Model.CoorSysPars(); Model.CoorSysPars gdls = DAL.CoorSysPars.GetModel("GD", mcs.MDZBXM); gd.ID = gdls.ID; gd.YSZBXM = "GD"; gd.YSRemarkName = mcs.YSRemarkName; gd.MDZBXM = mcs.MDZBXM; gd.MDRemarkName = mcs.MDRemarkName; gd.X = coortrana.cs2.dx; gd.Y = coortrana.cs2.dy; gd.Z = coortrana.cs2.dz; gd.m = coortrana.cs2.m0 * 1000000.0; gd.aa = coortrana.cs2.Qx * hudumiao; gd.bb = coortrana.cs2.Qy * hudumiao; gd.cc = coortrana.cs2.Qz * hudumiao; gd.YSMajorAxis = mcs.YSMajorAxis; gd.YSDAlpha = mcs.YSDAlpha; gd.YSe2 = mcs.YSe2; gd.MDMajorAxis = mcs.MDMajorAxis; gd.MDDAlpha = mcs.MDDAlpha; gd.MDe2 = mcs.MDe2; gd.CMeridian = mcs.CMeridian; gd.ProjElevation = mcs.ProjElevation; gd.OriginEast = mcs.OriginEast; gd.OriginNorth = mcs.OriginNorth; gd.AreaID = mcs.AreaID; DAL.CoorSysPars.Update(gd); Model.SysLog msl = new Model.SysLog(); msl.LogType = 0; msl.LogTime = DateTime.Now; msl.UserName = Convert.ToString(Session["UserName"]); msl.Remark = "修改了" + mcs.YSZBXM + "到" + mcs.MDZBXM + "的转换参数"; DAL.SysLog.Add(msl); result += "保存成功,请稍后退出系统,系统正在发送邮件通知用户"; Thread Noticethread = new Thread(NoticeRTKUser); Noticethread.Start(gd.MDZBXM); return(true); }
private bool AddData() { try { Model.CoorSysPars mcs = GetModelFromRequest(); if (!ValidateCoorPara(mcs)) { return(false); } mcs.YSMajorAxis = 6378137; mcs.YSDAlpha = 298.257223563; mcs.YSe2 = 0.00669438000426083; if (Request["DesEllip"] == "84") { mcs.MDMajorAxis = 6378137; mcs.MDDAlpha = 298.257223563; mcs.MDe2 = 0.00669438000426083; } else if (Request["DesEllip"] == "54") { mcs.MDMajorAxis = 6378245; mcs.MDDAlpha = 298.3; mcs.MDe2 = 0.00669342161454287; } else if (Request["DesEllip"] == "80") { mcs.MDMajorAxis = 6378140; mcs.MDDAlpha = 298.257; mcs.MDe2 = 0.00669438498631463; } else if (Request["DesEllip"] == "0") { mcs.MDMajorAxis = Convert.ToDouble(Request["MDMajorAxis"].Trim()); double a = mcs.MDMajorAxis; double f = Convert.ToDouble(Request["MDDAlpha"].Trim()); mcs.MDDAlpha = f; double b = a - a / f; double e12 = (Math.Pow(a, 2) - Math.Pow(b, 2)) / Math.Pow(a, 2); mcs.MDe2 = e12; } //if (Regex.IsMatch(TextBox_AddMDMajorAxis.Text.Trim(), @"^(-?[0-9]*[.]*[0-9]{0,20})$")) //{ // mcs.MDMajorAxis = Convert.ToDouble(TextBox_AddMDMajorAxis.Text.Trim()); //} //else //{ // ExtAspNet.Alert.Show("输入有误,请慎重修改", "提示", ExtAspNet.MessageBoxIcon.Information); // return; //} //if (Regex.IsMatch(TextBox_AddMDe2.Text.Trim(), @"^(-?[0-9]*[.]*[0-9]{0,20})$")) //{ // mcs.MDe2 = Convert.ToDouble(TextBox_AddMDe2.Text.Trim()); //} //else //{ // ExtAspNet.Alert.Show("输入有误,请慎重修改", "提示", ExtAspNet.MessageBoxIcon.Information); // return; //} mcs.AreaID = Convert.ToInt32(Request["WorkArea"]); DAL.CoorSysPars.Add(mcs); //加入OFormerCoorSysPars Model.OFormerCoorSysPars mofcsp = new Model.OFormerCoorSysPars(); mofcsp.aa = mcs.aa; mofcsp.bb = mcs.bb; mofcsp.cc = mcs.cc; mofcsp.CMeridian = mcs.CMeridian; mofcsp.EndTime = DateTime.Now; mofcsp.IsFormer = 0; mofcsp.m = mcs.m; mofcsp.MDDAlpha = mcs.MDDAlpha; mofcsp.MDe2 = mcs.MDe2; mofcsp.MDMajorAxis = mcs.MDMajorAxis; mofcsp.MDRemarkName = mcs.MDRemarkName; mofcsp.MDZBXM = mcs.MDZBXM; mofcsp.ProjElevation = mcs.ProjElevation; mofcsp.StartTime = DateTime.Now; mofcsp.X = mcs.X; mofcsp.Y = mcs.Y; mofcsp.YSDAlpha = mcs.YSDAlpha; mofcsp.YSe2 = mcs.YSe2; mofcsp.YSMajorAxis = mcs.YSMajorAxis; mofcsp.YSRemarkName = mcs.YSRemarkName; mofcsp.YSZBXM = mcs.YSZBXM; mofcsp.Z = mcs.Z; mofcsp.OriginEast = mcs.OriginEast; mofcsp.OriginNorth = mcs.OriginNorth; DAL.FormerCoorSysPars.Add(mofcsp); Model.OCoorSysPars mocsp = DAL.CoorSysPars.GetOModel(mcs.YSZBXM, mcs.MDZBXM); //加入GDCoorSysXYZ Model.GDCoorSysXYZ mgdcs = new Model.GDCoorSysXYZ(); mgdcs.YSZBXM = mocsp.YSZBXM; mgdcs.MDZBXM = mocsp.MDZBXM; Random r = new Random(); mgdcs.X = r.Next(-4, 3) + r.NextDouble(); double xs = (mocsp.X + mgdcs.X) * 10 - Math.Floor(mocsp.X * 10 + mgdcs.X * 10); xs = 1 - xs; mgdcs.X = mgdcs.X + xs / 10; mgdcs.Y = r.Next(2, 5) + r.NextDouble(); xs = (mocsp.Y + mgdcs.Y) * 10 - Math.Floor(mocsp.Y * 10 + mgdcs.Y * 10); xs = 1 - xs; mgdcs.Y += xs / 10; mgdcs.Z = r.Next(1, 4) + r.NextDouble(); xs = (mocsp.Z + mgdcs.Z) * 10 - Math.Floor(mocsp.Z * 10 + mgdcs.Z * 10); xs = 1 - xs; mgdcs.Z += xs / 10; mgdcs.aa = (double)r.Next(1, 9) / 100.0 + (double)r.Next(1, 9) / 1000.0; xs = (mocsp.aa + mgdcs.aa) * 1000 - Math.Floor(mocsp.aa * 1000 + mgdcs.aa * 1000); xs = 1 - xs; mgdcs.aa += xs / 1000; mgdcs.bb = (double)r.Next(1, 9) / 100.0 + (double)r.Next(1, 9) / 1000.0; xs = (mocsp.bb + mgdcs.bb) * 1000 - Math.Floor(mocsp.bb * 1000 + mgdcs.bb * 1000); xs = 1 - xs; mgdcs.bb += xs / 1000; mgdcs.cc = (double)r.Next(1, 9) / 100.0 + (double)r.Next(1, 9) / 1000.0; xs = (mocsp.cc + mgdcs.cc) * 1000 - Math.Floor(mocsp.cc * 1000 + mgdcs.cc * 1000); xs = 1 - xs; mgdcs.cc += xs / 1000; // mgdcs.aa = 0; mgdcs.bb = 0; mgdcs.cc = 0; ///////////////////////////Not sure/////////////////////////// if (Request["md"] == "0") { mgdcs.aa = 0; mgdcs.bb = 0; mgdcs.cc = 0; mgdcs.X = 0; mgdcs.Y = 0; mgdcs.Z = 0; } DAL.GDCoorSysXYZ.Add(mgdcs); double hudumiao = (180.0 / Math.PI) * 3600; Canshu csk = new Canshu(); csk.dx = mocsp.X; csk.dy = mocsp.Y; csk.dz = mocsp.Z; csk.m0 = mocsp.m / 1000000.0; csk.Qx = mocsp.aa / hudumiao; csk.Qy = mocsp.bb / hudumiao; csk.Qz = mocsp.cc / hudumiao; CoorTrans coortrana = new CoorTrans(); coortrana.SetCanshu(csk); Model.GDCoorSysXYZ mgdc = DAL.GDCoorSysXYZ.GetModel(mcs.YSZBXM, mcs.MDZBXM); coortrana.CalCanshu(mgdc.X, mgdc.Y, mgdc.Z, mgdc.aa / hudumiao, mgdc.bb / hudumiao, mgdc.cc / hudumiao); Model.CoorSysPars gd = new Model.CoorSysPars(); gd.YSZBXM = "GD"; gd.YSRemarkName = "发布坐标系"; gd.MDZBXM = mcs.MDZBXM; gd.MDRemarkName = mcs.MDRemarkName; gd.X = coortrana.cs2.dx; gd.Y = coortrana.cs2.dy; gd.Z = coortrana.cs2.dz; gd.m = coortrana.cs2.m0 * 1000000.0; gd.aa = coortrana.cs2.Qx * hudumiao; gd.bb = coortrana.cs2.Qy * hudumiao; gd.cc = coortrana.cs2.Qz * hudumiao; gd.YSMajorAxis = mcs.YSMajorAxis; gd.YSDAlpha = mcs.YSDAlpha; gd.YSe2 = mcs.YSe2; gd.MDMajorAxis = mcs.MDMajorAxis; gd.MDDAlpha = mcs.MDDAlpha; gd.MDe2 = mcs.MDe2; gd.CMeridian = mcs.CMeridian; gd.ProjElevation = mcs.ProjElevation; gd.OriginNorth = mcs.OriginNorth; gd.OriginEast = mcs.OriginEast; gd.AreaID = mcs.AreaID; DAL.CoorSysPars.Add(gd); Model.SysLog msl = new Model.SysLog(); msl.LogType = 0; msl.LogTime = DateTime.Now; msl.UserName = Convert.ToString(Session["UserName"]); msl.Remark = "添加了" + mcs.YSZBXM + "到" + mcs.MDZBXM + "的转换参数"; DAL.SysLog.Add(msl); result += "添加参数成功"; return(true); } catch (Exception e) { result += e.Message; return(false); } }