using BasAid.Client.ServiceReference;
namespace BasAid.Client
{
public partial class Frm_main : Form
{
ChannelFactory<IStreamed> factory = new ChannelFactory<IStreamed>("NetTcpBinding_IStreamed");
public static IStreamed service = null;
public static DataSet dsConfig = null;
public static Config cf = null;
private static bool ynZB = false;
private static string type = "wt";
private FormStart fs = null;
private int time = 0; public Frm_main()
{
InitializeComponent();
} private void Frm_main_Load(object sender, EventArgs e)
{
load();
}
private void load()
{
this.txt_station_id.Text = BasAid.Client.Properties.Settings.Default.station_id;
this.txt_station_name.Text = BasAid.Client.Properties.Settings.Default.station_name;
this.txt_down.Text = BasAid.Client.Properties.Settings.Default.down_path;
this.txt_uload.Text = BasAid.Client.Properties.Settings.Default.down_path_old;
this.txt_time.Text = BasAid.Client.Properties.Settings.Default.time; time = Convert.ToInt16(this.txt_time.Text) * 60; cf = new Config();
cf.station_id = BasAid.Client.Properties.Settings.Default.station_id;
cf.station_name = BasAid.Client.Properties.Settings.Default.station_name;
cf.strPathIn = BasAid.Client.Properties.Settings.Default.down_path;
cf.strPathInOld = BasAid.Client.Properties.Settings.Default.down_path_old; service = factory.CreateChannel(); try
{
bool bo = service.GetStatus();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
this.Close();
} dsConfig = returnConfiguration(cf.station_id, cf.station_name);
this.dataGridView1.DataSource = dsConfig.Tables["db_data_trans_ices"];
type = dsConfig.Tables["db_data_trans_ices"].Rows[0]["type"].ToString();
if (txt_station_id.Text == "0000" || txt_station_id.Text == "XZZZ")
{
this.but_upload.Visible = false;
this.but_auto.Visible = true;
this.but_down.Text = "开始导入数据";
ynZB = true;
}
else
{
this.but_upload.Visible = true;
this.but_auto.Visible = false;
this.but_down.Text = "数据下载";
ynZB = false;
}
}
/// <summary>
/// 读取配置文件,并下载返回
/// </summary>
/// <param name="newFilePath"></param>
/// <param name="oldFilePath"></param>
/// <returns></returns>
private DataSet returnConfiguration(string station_id, string station_name)
{
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); //定义观察者
try
{
DataSet ds = (DataSet)service.GetConfiguration(station_id, station_name);
return ds;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
watch.Stop();
}
return null;
} #region 系统设置
/// <summary>
/// 改变txtbox状态为可录入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void but_set_Click(object sender, EventArgs e)
{
string str = Microsoft.VisualBasic.Interaction.InputBox("请输入认证码!", "提示", "", -1, -1);
if (str == dsConfig.Tables["sys_code_ices"].Rows[0][0].ToString())
{
this.txt_station_id.ReadOnly = false;
this.txt_station_name.ReadOnly = false;
this.txt_time.ReadOnly = false;
this.but_select1.Enabled = true;
this.but_select2.Enabled = true;
}
else
{
MessageBox.Show("你输入的认证码不准确,请联系信息中心修改!", "提示!");
}
}
/// <summary>
/// 保存当前设置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void but_save_Click(object sender, EventArgs e)
{
Properties.Settings.Default.station_id = this.txt_station_id.Text.Trim();
Properties.Settings.Default.station_name = this.txt_station_name.Text.Trim();
Properties.Settings.Default.down_path_old = this.txt_uload.Text.Trim();
Properties.Settings.Default.down_path = this.txt_down.Text.Trim();
Properties.Settings.Default.time = this.txt_time.Text.Trim();
Properties.Settings.Default.Save();
this.txt_station_id.ReadOnly = true;
this.txt_station_name.ReadOnly = true;
this.but_select1.Enabled = false;
this.but_select2.Enabled = false;
this.txt_time.ReadOnly = true;
load();
}
/// <summary>
/// 选择下载文件路径
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void but_select1_Click(object sender, EventArgs e)
{
DialogResult dr = this.folderBrowserDialog.ShowDialog();
if (dr == DialogResult.OK)
this.txt_down.Text = this.folderBrowserDialog.SelectedPath + "\\";
}
/// <summary>
/// 先择上传文件路径
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void but_select2_Click(object sender, EventArgs e)
{
DialogResult dr = this.folderBrowserDialog.ShowDialog();
if (dr == DialogResult.OK)
this.txt_uload.Text = this.folderBrowserDialog.SelectedPath + "\\";
}
#endregion 系统设置
/// <summary>
/// 数据导出
/// </summary>
private void outputData()
{
try{
listBoxState.Items.Add(DateTime.Now.ToString() + " 开始导出数据");
string str = Upload.OutputData(type);
fs.Close();
listBoxState.Items.Add(DateTime.Now.ToString() + " " + str);
listBoxState.Items.Add("");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
fs.Close();
Thread.CurrentThread.Abort();
}
}
/// <summary>
/// 总部数据导入
/// </summary>
private void importDataZB()
{
listBoxState.Items.Add(DateTime.Now.ToString() + " 开始导入数据");
string str = ZBDown.ImportData(type);
fs.Close();
listBoxState.Items.Add(DateTime.Now.ToString() + " " + str);
listBoxState.Items.Add("");
//}
//catch (Exception ex)
//{
// MessageBox.Show(ex.ToString());
// fs.Close();
// Thread.CurrentThread.Abort();
//}
}
/// <summary>
/// 分部数据导入
/// </summary>
private void importData()
{
listBoxState.Items.Add(DateTime.Now.ToString() + " 开始导入数据");
string str = Down.ImportData(type);
fs.Close();
listBoxState.Items.Add(DateTime.Now.ToString() + " " + str);
listBoxState.Items.Add("");
//}
//catch (Exception ex)
//{
// MessageBox.Show(ex.ToString());
// fs.Close();
// Thread.CurrentThread.Abort();
//}
} private void but_upload_Click(object sender, EventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
Thread th = new Thread(this.outputData);
th.Start();
startFrm();
} private void but_down_Click(object sender, EventArgs e)
{
if (ynZB)
{
Control.CheckForIllegalCrossThreadCalls = false;
Thread th = new Thread(this.importDataZB);
th.Start();
}
else
{
Control.CheckForIllegalCrossThreadCalls = false;
Thread ths = new Thread(this.importData);
ths.Start();
}
startFrm();
} public void startFrm()
{
fs = new FormStart();
fs.Height = this.Height;
fs.Width = this.Width;
fs.ShowInTaskbar = false;
fs.Opacity = 0.8;
fs.StartPosition = FormStartPosition.CenterParent;
fs.ShowDialog();
} private void but_auto_Click(object sender, EventArgs e)
{
if (this.but_auto.Text != "停止传输")
{
this.but_upload.Enabled = false;
this.but_down.Enabled = false;
this.but_auto.Text = "停止传输";
this.timer.Interval = time*1000;
this.timer.Start();
}
else
{
this.timer.Stop();
this.but_upload.Enabled = true;
this.but_down.Enabled = true;
this.but_auto.Text = "自动传输";
}
} private void timer_Tick(object sender, EventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
Thread th = new Thread(this.importDataZB);
th.Start();
} private void listBoxState_SelectedIndexChanged(object sender, EventArgs e)
{ }
}
}这是同事写的C#,真心不懂点击but_set按钮,他会提示请输入认证码,请问怎么样找到这个认证码是什么。谢谢
namespace BasAid.Client
{
public partial class Frm_main : Form
{
ChannelFactory<IStreamed> factory = new ChannelFactory<IStreamed>("NetTcpBinding_IStreamed");
public static IStreamed service = null;
public static DataSet dsConfig = null;
public static Config cf = null;
private static bool ynZB = false;
private static string type = "wt";
private FormStart fs = null;
private int time = 0; public Frm_main()
{
InitializeComponent();
} private void Frm_main_Load(object sender, EventArgs e)
{
load();
}
private void load()
{
this.txt_station_id.Text = BasAid.Client.Properties.Settings.Default.station_id;
this.txt_station_name.Text = BasAid.Client.Properties.Settings.Default.station_name;
this.txt_down.Text = BasAid.Client.Properties.Settings.Default.down_path;
this.txt_uload.Text = BasAid.Client.Properties.Settings.Default.down_path_old;
this.txt_time.Text = BasAid.Client.Properties.Settings.Default.time; time = Convert.ToInt16(this.txt_time.Text) * 60; cf = new Config();
cf.station_id = BasAid.Client.Properties.Settings.Default.station_id;
cf.station_name = BasAid.Client.Properties.Settings.Default.station_name;
cf.strPathIn = BasAid.Client.Properties.Settings.Default.down_path;
cf.strPathInOld = BasAid.Client.Properties.Settings.Default.down_path_old; service = factory.CreateChannel(); try
{
bool bo = service.GetStatus();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
this.Close();
} dsConfig = returnConfiguration(cf.station_id, cf.station_name);
this.dataGridView1.DataSource = dsConfig.Tables["db_data_trans_ices"];
type = dsConfig.Tables["db_data_trans_ices"].Rows[0]["type"].ToString();
if (txt_station_id.Text == "0000" || txt_station_id.Text == "XZZZ")
{
this.but_upload.Visible = false;
this.but_auto.Visible = true;
this.but_down.Text = "开始导入数据";
ynZB = true;
}
else
{
this.but_upload.Visible = true;
this.but_auto.Visible = false;
this.but_down.Text = "数据下载";
ynZB = false;
}
}
/// <summary>
/// 读取配置文件,并下载返回
/// </summary>
/// <param name="newFilePath"></param>
/// <param name="oldFilePath"></param>
/// <returns></returns>
private DataSet returnConfiguration(string station_id, string station_name)
{
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); //定义观察者
try
{
DataSet ds = (DataSet)service.GetConfiguration(station_id, station_name);
return ds;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
watch.Stop();
}
return null;
} #region 系统设置
/// <summary>
/// 改变txtbox状态为可录入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void but_set_Click(object sender, EventArgs e)
{
string str = Microsoft.VisualBasic.Interaction.InputBox("请输入认证码!", "提示", "", -1, -1);
if (str == dsConfig.Tables["sys_code_ices"].Rows[0][0].ToString())
{
this.txt_station_id.ReadOnly = false;
this.txt_station_name.ReadOnly = false;
this.txt_time.ReadOnly = false;
this.but_select1.Enabled = true;
this.but_select2.Enabled = true;
}
else
{
MessageBox.Show("你输入的认证码不准确,请联系信息中心修改!", "提示!");
}
}
/// <summary>
/// 保存当前设置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void but_save_Click(object sender, EventArgs e)
{
Properties.Settings.Default.station_id = this.txt_station_id.Text.Trim();
Properties.Settings.Default.station_name = this.txt_station_name.Text.Trim();
Properties.Settings.Default.down_path_old = this.txt_uload.Text.Trim();
Properties.Settings.Default.down_path = this.txt_down.Text.Trim();
Properties.Settings.Default.time = this.txt_time.Text.Trim();
Properties.Settings.Default.Save();
this.txt_station_id.ReadOnly = true;
this.txt_station_name.ReadOnly = true;
this.but_select1.Enabled = false;
this.but_select2.Enabled = false;
this.txt_time.ReadOnly = true;
load();
}
/// <summary>
/// 选择下载文件路径
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void but_select1_Click(object sender, EventArgs e)
{
DialogResult dr = this.folderBrowserDialog.ShowDialog();
if (dr == DialogResult.OK)
this.txt_down.Text = this.folderBrowserDialog.SelectedPath + "\\";
}
/// <summary>
/// 先择上传文件路径
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void but_select2_Click(object sender, EventArgs e)
{
DialogResult dr = this.folderBrowserDialog.ShowDialog();
if (dr == DialogResult.OK)
this.txt_uload.Text = this.folderBrowserDialog.SelectedPath + "\\";
}
#endregion 系统设置
/// <summary>
/// 数据导出
/// </summary>
private void outputData()
{
try{
listBoxState.Items.Add(DateTime.Now.ToString() + " 开始导出数据");
string str = Upload.OutputData(type);
fs.Close();
listBoxState.Items.Add(DateTime.Now.ToString() + " " + str);
listBoxState.Items.Add("");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
fs.Close();
Thread.CurrentThread.Abort();
}
}
/// <summary>
/// 总部数据导入
/// </summary>
private void importDataZB()
{
listBoxState.Items.Add(DateTime.Now.ToString() + " 开始导入数据");
string str = ZBDown.ImportData(type);
fs.Close();
listBoxState.Items.Add(DateTime.Now.ToString() + " " + str);
listBoxState.Items.Add("");
//}
//catch (Exception ex)
//{
// MessageBox.Show(ex.ToString());
// fs.Close();
// Thread.CurrentThread.Abort();
//}
}
/// <summary>
/// 分部数据导入
/// </summary>
private void importData()
{
listBoxState.Items.Add(DateTime.Now.ToString() + " 开始导入数据");
string str = Down.ImportData(type);
fs.Close();
listBoxState.Items.Add(DateTime.Now.ToString() + " " + str);
listBoxState.Items.Add("");
//}
//catch (Exception ex)
//{
// MessageBox.Show(ex.ToString());
// fs.Close();
// Thread.CurrentThread.Abort();
//}
} private void but_upload_Click(object sender, EventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
Thread th = new Thread(this.outputData);
th.Start();
startFrm();
} private void but_down_Click(object sender, EventArgs e)
{
if (ynZB)
{
Control.CheckForIllegalCrossThreadCalls = false;
Thread th = new Thread(this.importDataZB);
th.Start();
}
else
{
Control.CheckForIllegalCrossThreadCalls = false;
Thread ths = new Thread(this.importData);
ths.Start();
}
startFrm();
} public void startFrm()
{
fs = new FormStart();
fs.Height = this.Height;
fs.Width = this.Width;
fs.ShowInTaskbar = false;
fs.Opacity = 0.8;
fs.StartPosition = FormStartPosition.CenterParent;
fs.ShowDialog();
} private void but_auto_Click(object sender, EventArgs e)
{
if (this.but_auto.Text != "停止传输")
{
this.but_upload.Enabled = false;
this.but_down.Enabled = false;
this.but_auto.Text = "停止传输";
this.timer.Interval = time*1000;
this.timer.Start();
}
else
{
this.timer.Stop();
this.but_upload.Enabled = true;
this.but_down.Enabled = true;
this.but_auto.Text = "自动传输";
}
} private void timer_Tick(object sender, EventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
Thread th = new Thread(this.importDataZB);
th.Start();
} private void listBoxState_SelectedIndexChanged(object sender, EventArgs e)
{ }
}
}这是同事写的C#,真心不懂点击but_set按钮,他会提示请输入认证码,请问怎么样找到这个认证码是什么。谢谢
解决方案 »
- 很急 关于C/S 中treeview图标动态绑定不显示的问题
- 高手请进,疑难问题
- 求助:WCF宿主到Windows service中 怎么加密?
- 急救!!!
- 关于vs2005 第三控件的问题
- 在线等待,高分求解,如何修改编译好的Winform程序?
- to 版主:关于CSDN结贴界面的UI更改建议
- 请问.net与J2EE的开发效率哪个高?(在.net和java版同时发问)
- 如何使用DataGrid的数据格式表达式?在线高分提问!
- 在线等待:我用Graphics 上画了一个图,我现在要将整个图放大该如何做??
- 问个在WPF中的TextBox中提取文本内容的小问题 求大家帮忙
- WPF 打包安装后不能运行
dsConfig.Tables["sys_code_ices"].Rows[0][0]
这里拿到的
在ds .Tables["sys_code_ices"]里,所以应该是service.GetConfiguration获取到的验证码
/// 读取配置文件,并下载返回
/// </summary>
/// <param name="newFilePath"></param>
/// <param name="oldFilePath"></param>
/// <returns></returns>
private DataSet returnConfiguration(string station_id, string station_name)
{
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); //定义观察者
try
{
DataSet ds = (DataSet)service.GetConfiguration(station_id, station_name);
return ds;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
watch.Stop();
}
return null;
}在这个方法里面获取到的啊
service = factory.CreateChannel();
去factory.CreateChannel();方法里面找
factory.CreateChannel这个方法里面全是注释呀
[code=csharp] // 摘要:
// 创建到指定终结点地址的指定类型的通道。
//
// 返回结果:
// 工厂创建的 System.ServiceModel.Channels.IChannel 类型的 TChannel。
public TChannel CreateChannel();
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.17929
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------namespace BasAid.Client.ServiceReference {
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="ServiceReference.IStreamed")]
public interface IStreamed {
// CODEGEN: 消息 FileWrapper 的包装名称(FileWrapper)以后生成的消息协定与默认值(UploadFile)不匹配
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IStreamed/UploadFile", ReplyAction="http://tempuri.org/IStreamed/UploadFileResponse")]
BasAid.Client.ServiceReference.result UploadFile(BasAid.Client.ServiceReference.FileWrapper request);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IStreamed/UploadFile", ReplyAction="http://tempuri.org/IStreamed/UploadFileResponse")]
System.Threading.Tasks.Task<BasAid.Client.ServiceReference.result> UploadFileAsync(BasAid.Client.ServiceReference.FileWrapper request);
// CODEGEN: 消息 filePath 的包装名称(filePath)以后生成的消息协定与默认值(SreamFromFile)不匹配
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IStreamed/SreamFromFile", ReplyAction="http://tempuri.org/IStreamed/SreamFromFileResponse")]
BasAid.Client.ServiceReference.FileWrapper SreamFromFile(BasAid.Client.ServiceReference.filePath request);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IStreamed/SreamFromFile", ReplyAction="http://tempuri.org/IStreamed/SreamFromFileResponse")]
System.Threading.Tasks.Task<BasAid.Client.ServiceReference.FileWrapper> SreamFromFileAsync(BasAid.Client.ServiceReference.filePath request);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IStreamed/GetConfiguration", ReplyAction="http://tempuri.org/IStreamed/GetConfigurationResponse")]
System.Data.DataSet GetConfiguration(string station_id, string station_name);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IStreamed/GetConfiguration", ReplyAction="http://tempuri.org/IStreamed/GetConfigurationResponse")]
System.Threading.Tasks.Task<System.Data.DataSet> GetConfigurationAsync(string station_id, string station_name);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IStreamed/GetStatus", ReplyAction="http://tempuri.org/IStreamed/GetStatusResponse")]
bool GetStatus();
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IStreamed/GetStatus", ReplyAction="http://tempuri.org/IStreamed/GetStatusResponse")]
System.Threading.Tasks.Task<bool> GetStatusAsync();
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IStreamed/outputData", ReplyAction="http://tempuri.org/IStreamed/outputDataResponse")]
byte[] outputData(string strSQL);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IStreamed/outputData", ReplyAction="http://tempuri.org/IStreamed/outputDataResponse")]
System.Threading.Tasks.Task<byte[]> outputDataAsync(string strSQL);
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="FileWrapper", WrapperNamespace="http://tempuri.org/", IsWrapped=true)]
public partial class FileWrapper {
[System.ServiceModel.MessageHeaderAttribute(Namespace="http://tempuri.org/")]
public string FilePath;这个是 service.GetStatus()里面的,谢谢高手帮忙看看。
你去发布webservice的人,找webservce项目,代码在那个项目里啊
你去发布webservice的人,找webservce项目,代码在那个项目里啊那个人辞职走掉了,联系不上了,所以才来一步一步研究找密码。
一般来说webservice会单独创建一个项目
你可以先找下当前解决方案里面是否有web项目
如果有看看这个web项目就是你调用的ws项目