/// <summary>
        /// 查询部门列表
        /// </summary>
        /// <returns></returns>
        public List<SDepartment> QuerySDepartment()
        {
            //return Task.Factory.StartNew(() =>
            {
                try
                {
                    SocketMessage sm = new SocketMessage(Request.QUERY_SDEPARTMENT_REQUEST);
                    //string request = JsonConvert.SerializeObject(Request.QUERY_DEPARTMENT_REQUEST.ToString());
                    //scoket发送请求信息
                    ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                    //scoket接收请求信息
                    recLength = ClientSocket.Receive(recivebuffer);
                    string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                    string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                    if (Msg[0] == Response.QUERY_SDEPARTMENT_SUCCESS.ToString())
                    {
                        List<SDepartment> list = new List<SDepartment>();

                        list = JsonConvert.DeserializeObject<List<SDepartment>>(Msg[2]);

                        return list;
                    }
                    else
                    {
                        Logging.AddLog("查询部门列表失败!" + recMsg);
                        return null;
                    }
                }
                catch
                {
                    Logging.AddLog("查询部门列表失败(服务器连接中断)!");
                    return null;
                }
                //});
            }
        }
        /// <summary>
        /// 查询部门员工
        /// </summary>
        /// <param name="departmentID"></param>
        /// <returns></returns>
        public List<Employee> QueryEmployeeByDepartmentID(int departmentID)
        {
            //return Task.Factory.StartNew(() =>
            {
                try
                {
                    SocketMessage sm = new SocketMessage(Request.QUERY_EMPLOYEE_REQUEST, departmentID);

                    ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                    recLength = ClientSocket.Receive(recivebuffer);
                    string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                    string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                    if (Msg[0] == Response.QUERY_EMPLOYEE_SUCCESS.ToString())
                    {
                        List<Employee> emp = new List<Employee>();
                        emp = JsonConvert.DeserializeObject<List<Employee>>(Msg[2]);

                        return emp;
                    }
                    else
                    {
                        Logging.AddLog("查询部门员工失败!");
                        return null;
                    }
                }
                catch
                {
                    Logging.AddLog("查询员工列表失败(服务器连接中断)!");
                    return null;
                }
            //});
            }
        }
        /// <summary>
        /// 添加人员
        /// </summary>
        /// <param name="emp"></param>
        /// <returns></returns>
        public int InsertEmployee(Employee emp)
        {
            //return Task.Factory.StartNew(() =>
            {
                try
                {
                    SocketMessage sm = new SocketMessage(Request.INSERT_EMPLOYEE_REQUEST, emp);
                    ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                    recLength = ClientSocket.Receive(recivebuffer);
                    string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                    string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);
                    
                    if (Msg[0] == Response.INSERT_EMPLOYEE_SUCCESS.ToString())
                    {
                        Logging.AddLog("添加人员成功!");
                        return Convert.ToInt32(Msg[2]);
                    }
                    else if (Msg[0] == Response.INSERT_EMPLOYEE_EXIST.ToString())
                    {
                        Logging.AddLog("员工已经存在,无法继续插入");
                        return -2;
                    }
                    else
                    {
                        Logging.AddLog("添加人员失败!");
                        return -1;
                    }
                }
                catch
                {
                    Logging.AddLog("添加人员失败(服务器连接中断)!");
                    return 0;
                }
            //});
            }
        }
        public List<ContractItem> QueryContractItemByName(Search search)
        {
            List<ContractItem> items = new List<ContractItem>();
            try
            {
                SocketMessage sm = new SocketMessage(Request.QUERY_PROJECT_ITEM_BY_NAME_REQUEST, search);
                ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                recLength = ClientSocket.Receive(recivebuffer);
                string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                if (Msg[0] == Response.QUERY_PROJECT_ITEM_BY_NAME_SUCCESS.ToString())
                {

                    items = JsonConvert.DeserializeObject<List<ContractItem>>(Msg[2]);

                    return items;
                }
                else
                {
                    Logging.AddLog("子项目名称查询失败!");
                    return null;
                }
            }
            catch
            {
                Logging.AddLog("子项目名称查询失败(服务器连接中断)!");
                return null;
            }
        }
        /// <summary>
        /// 查询已经签字通过的签单列表
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public List<SHDJContract> QuerySignedContract(int Id)
        {
            //return Task.Factory.StartNew(() =>
            {
                try
                {
                    SocketMessage sm = new SocketMessage(Request.QUERY_SIGNED_CONTRACT_REQUEST, Id);
                    ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                    recLength = ClientSocket.Receive(recivebuffer);
                    string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                    string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                    if (Msg[0] == Response.QUERY_SIGNED_CONTRACT_SUCCESS.ToString())
                    {
                        List<SHDJContract> list = new List<SHDJContract>();
                        list = JsonConvert.DeserializeObject<List<SHDJContract>>(Msg[2]);

                        return list;
                    }
                    else
                    {
                        Logging.AddLog("查询已办列表失败!");
                        return null;
                    }
                }
                catch
                {
                    Logging.AddLog("查询已办列表失败(服务器连接中断)!");
                    return null;
                }
            //});
            }
        }
        /// <summary>
        /// 登陆验证
        /// </summary>
        /// <param name="UserName"></param>
        /// <param name="PassWord"></param>
        /// <returns></returns>
        public Task<Employee> Login(string UserName, string PassWord)
        {
            return Task.Factory.StartNew(() =>
            {
                    User user = new User { Username = UserName, Password = PassWord };
                    SocketMessage sm = new SocketMessage(Request.LOGIN_REQUEST, user);
                    try
                    {
                        //  scoket发送请求信息
                        ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                        //socket接收信息
                        recLength = ClientSocket.Receive(recivebuffer);
                        string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                        string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);
                        
                        if (Msg[0] == Response.LOGIN_SUCCESS.ToString().Trim())
                        {
                            //将接收的信息(json格式)转化为类
                            Employee emp = new Employee();
                            emp = JsonConvert.DeserializeObject<Employee>(Msg[2]);

                            return emp;
                        }
                        else
                        {
                            Logging.AddLog("登录失败!");
                            return null;
                        }
                    }
                    catch
                    {
                        if (ClientSocket.Connected)
                        {
                            return null;
                        }
                        else
                        {
                            Logging.AddLog("连接服务器失败!");
                            return null;
                        }
                    }
                });
        }
        /// <summary>
        /// 查询模板信息
        /// </summary>
        /// <returns></returns>
        public async Task<List<Templete>> QueryContractTemplate()
        {
            return await Task.Factory.StartNew(() =>
            {
                try
                {
                    SocketMessage sm = new SocketMessage(Request.QUERY_CONTRACT_TEMPLATE_REQUEST);
                    ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                    recLength = ClientSocket.Receive(recivebuffer);
                    string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                    string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                    if (Msg[0] == Response.QUERY_CONTRACT_TEMPLATE_SUCCESS.ToString())
                    {
                        List<Templete> list = new List<Templete>();
                        list = JsonConvert.DeserializeObject<List<Templete>>(Msg[2]);

                        return list;
                    }
                    else
                    {
                        Logging.AddLog("查询部模板列表失败!");
                        return null;
                    }
                }
                catch
                {
                    Logging.AddLog("查询模板列表失败(服务器连接中断)!");
                    return null;
                }
            
                
            });
           
        }
        /// <summary>
        /// 删除部门
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public string DeleteDepartment(int Id)
        {
            //return Task.Factory.StartNew(() =>
            {
                try
                {
                    SocketMessage sm = new SocketMessage(Request.DELETE_DEPARTMENT_REQUEST, Id);
                    ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                    recLength = ClientSocket.Receive(recivebuffer);
                    string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                    string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                    if (Msg[0] == Response.DELETE_DEPARTMENT_SUCCESS.ToString())
                    {
                        Logging.AddLog("删除部门成功!");
                    }
                    else
                    {
                        Logging.AddLog("删除部门失败!");
                    }
                    return Msg[0];
                }
                catch
                {
                    Logging.AddLog("删除部门失败(服务器连接中断)!");
                    return "服务器连接中断";
                }
            //});
            }
        }
        public double StatisticDepartmentYearCategoryExpense(Search search)
        {
            ContractWorkload workload = null;

            try
            {
                SocketMessage sm = new SocketMessage(Request.STATISTIC_DEP_YEAR_CATEGORY_REQUEST, search);
                //scoket发送请求信息
                ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                //scoket接收请求信息
                recLength = ClientSocket.Receive(recivebuffer);
                string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);


                if (Msg[0] == Response.STATISTIC_DEP_YEAR_CATEGORY_SUCCESS.ToString())
                {
                    workload = JsonConvert.DeserializeObject<ContractWorkload>(Msg[2]);

                    Logging.AddLog("获取当前部门" + search.SDepartmentShortlCall.ToString() + search.Year.ToString() + search.CategoryId.ToString() + "成功!");
                }
                else
                {
                    Logging.AddLog("获取当前部门" + search.SDepartmentShortlCall.ToString() + search.Year.ToString() + search.CategoryId.ToString() + "失败!");
                }
            }
            catch
            {
                Logging.AddLog("获取总计申请额度(服务器连接中断)!");
                return 0;
            }

            return workload.Expense;

        }
示例#10
0
        public bool ReCreateHDJContract(string contractId)
        {
            ContractWorkload workload = null;

            try
            {
                SocketMessage sm = new SocketMessage(Request.RECREATE_HDJCONTRACT_REQUEST, contractId);
                //scoket发送请求信息
                ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                //scoket接收请求信息
                recLength = ClientSocket.Receive(recivebuffer);
                string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);


                if (Msg[0] == Response.RECREATE_HDJCONTRACT_SUCCESS.ToString())
                {
                    return true;
                    Logging.AddLog("重新生成会签单" + contractId.ToString( ) + "成功!");
                }
                else
                {
                    return false;
                    Logging.AddLog("重新生成会签单" + contractId.ToString() + "失败!");
                }
            }
            catch
            {
                Logging.AddLog("获取总计申请额度(服务器连接中断)!");
                return false;
            }


        }
示例#11
0
        public string ModifyProject(ContractProject project)
        {
            try
            {
                SocketMessage sm = new SocketMessage(Request.MODIFY_PROJECT_REQUEST, project);
                //scoket发送请求信息
                ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                //scoket接收请求信息
                recLength = ClientSocket.Receive(recivebuffer);
                string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                if (Msg[0] == Response.MODIFY_PROJECT_SUCCESS.ToString())
                {
                    Logging.AddLog("修改项目" + project.Project + "成功!");
                }
                else
                {
                    Logging.AddLog("修改项目" + project.Project + "失败!");
                }
                return Msg[0];
            }
            catch
            {
                Logging.AddLog("添加工作量失败(服务器连接中断)!");
                return "添加失败";
            }

        }
示例#12
0
        public string DeleteItem(int itemId)
        {
            try
            {
                SocketMessage sm = new SocketMessage(Request.DELETE_ITEM_REQUEST, itemId);
                //scoket发送请求信息
                ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                //scoket接收请求信息
                recLength = ClientSocket.Receive(recivebuffer);
                string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                if (Msg[0] == Response.INSERT_ITEM_SUCCESS.ToString())
                {
                    Logging.AddLog("添加工作量成功!");
                }
                else
                {
                    Logging.AddLog("添加工作量失败!");
                }
                return Msg[0];
            }
            catch
            {
                Logging.AddLog("添加工作量失败(服务器连接中断)!");
                return "添加失败";
            }

        }
示例#13
0
        //GET_DEP_CATE_YEAR_CON_COUNT_REQUEST
        public int GetDepartmentCategoryYearContractCount(Search search)
        {
            int count = -1;
            try
            {
                SocketMessage sm = new SocketMessage(Request.GET_DEP_CATE_YEAR_CON_COUNT_REQUEST, search);
                ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                recLength = ClientSocket.Receive(recivebuffer);
                string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                if (Msg[0] == Response.GET_DEP_CATE_YEAR_CON_COUNT_SUCCESS.ToString())
                {

                    count = JsonConvert.DeserializeObject<int>(Msg[2]);

                    return count;
                }
                else
                {
                    Logging.AddLog("获取当年已经签署的CATEGORY的会签单数目失败");
                    return -1;
                }
            }
            catch
            {
                Logging.AddLog("项目名称查询失败(服务器连接中断)!");
                return -1;
            }
        }
示例#14
0
        /// <summary>
        /// 查询特定模板信息
        /// </summary>
        /// <param name="tempId"></param>
        /// <returns></returns>
        public Templete GetContractTemplate(int tempId)
        {
            //return Task.Factory.StartNew(() =>
            {
                try
                {
                    SocketMessage sm = new SocketMessage(Request.GET_CONTRACT_TEMPLATE_REQUEST, tempId);
                    ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                    recLength = ClientSocket.Receive(recivebuffer);
                    string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                    string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                    if (Msg[0] == Response.GET_CONTRACT_TEMPLATE_SUCCESS.ToString())
                    {
                        Templete list = new Templete();
                        list = JsonConvert.DeserializeObject<Templete>(Msg[2]);

                        return list;
                    }
                    else
                    {
                        Logging.AddLog("查询特定模板列表失败!");
                        return null;
                    }
                }
                catch
                {
                    Logging.AddLog("查询特定模板列表失败(服务器连接中断)!");
                    return null;
                }
            }//);
        }
示例#15
0
        /// <summary>
        /// 下载会签单信息
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="filepath"></param>
        /// <returns></returns>
        public async Task DownloadHDJContract(string Id, string filepath)
        {
            await Task.Run(() =>
            {
                try
                {
                    SocketMessage sm = new SocketMessage(Request.DOWNLOAD_HDJCONTRACT_REQUEST, Id);
                    Socket download = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    download.Connect(new IPEndPoint(IP, 6060));
                    download.Send(Encoding.UTF8.GetBytes(sm.Package + "~"));
                    FileStream fs = new FileStream(filepath, FileMode.Create);

                    int len = 0;
                    int size = 0;
                    byte[] buffer = new byte[1024*1024];
                    //从终端不停的接受数据,然后写入文件里面,只到接受到的数据为0为止,则中断连接
                    while ((size = download.Receive(buffer, 0, buffer.Length, SocketFlags.None)) > 0)
                    {
                        fs.Write(buffer, 0, size);
                        len += size;
                    }


                    fs.Flush();
                    fs.Close();
                    download.Close();
                }
                catch
                {
                    
                }
            });
        }
示例#16
0
        /// <summary>
        /// 修改模板信息
        /// </summary>
        /// <param name="temp"></param>
        /// <returns></returns>
        public string ModifyContractTemplate(Templete temp)
        {
            //return Task.Factory.StartNew(() =>
            {
                try
                {
                    SocketMessage sm = new SocketMessage(Request.MODIFY_CONTRACT_TEMPLATE_REQUEST, temp);
                    ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                    recLength = ClientSocket.Receive(recivebuffer);
                    string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                    string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                    if (Msg[0] == Response.DELETE_CONTRACT_TEMPLATE_SUCCESS.ToString())
                    {
                        Logging.AddLog("修改模板成功!");
                    }
                    else
                    {
                        Logging.AddLog("修改模板失败!");
                    }
                    return Msg[0];
                }
                catch
                {
                    Logging.AddLog("修改模板失败(服务器连接中断)!");
                    return "服务器连接中断";
                }
            //});
            }
        }
示例#17
0
 /// <summary>
 /// 退出验证
 /// </summary>
 /// <returns></returns>
 public async Task Quit( )
 {
     //return Task.Factory.StartNew(() =>
     await Task.Run(() =>
     {
         SocketMessage sm = new SocketMessage(Request.QUIT_REQUEST);
         try
         {
             //  scoket发送请求信息
             ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));
         }
         catch( Exception ex )
         {
             Logging.AddLog("退出时异常" + ex.ToString());
         }
     });
 }  
示例#18
0
         /// <summary>
         /// 提交签单
         /// </summary>
         /// <param name="hdj"></param>
         /// <returns></returns>
        public string InsertHDJContract(HDJContract hdj)
        {
            //return Task.Factory.StartNew(() =>
            {
                try
                {
                    SocketMessage sm = new SocketMessage(Request.INSERT_HDJCONTRACT_REQUEST, hdj);
                    ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                    recLength = ClientSocket.Receive(recivebuffer);
                    string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                    string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                    if (Msg[0] == Response.INSERT_HDJCONTRACT_SUCCESS.ToString())
                    {
                        Logging.AddLog("提交签单成功!");
                    }
                    else
                    {
                        Logging.AddLog("提交签单失败!");
                    }
                    return Msg[0];
                }
                catch
                {
                    Logging.AddLog("提交签单失败(服务器连接中断)!");
                    return "服务器连接中断";
                }
            //});
            }
        }
示例#19
0
         public String ModifySDepartment(SDepartment department)
         {
             //return Task.Factory.StartNew(() =>
             {
                 try
                 {
                     SocketMessage sm = new SocketMessage(Request.MODIFY_SDEPARTMENT_REQUEST, department);
                     ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                     recLength = ClientSocket.Receive(recivebuffer);
                     string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);

                     string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                     if (Msg[0] == Response.MODIFY_SDEPARTMENT_SUCCESS.ToString())
                     {

                         Logging.AddLog("修改部门成功");
                     }
                     else
                     {
                         Logging.AddLog("修改部门失败!");
                     }
                     return Msg[0];
                 }
                 catch
                 {
                     Logging.AddLog("重置用户密码失败(服务器连接中断)!");
                     return "服务器连接中断";
                 }
                 //});
             }
         }
示例#20
0
        /// <summary>
        /// 查询会签单信息
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public Task<HDJContract> GetHDJContract(string Id)
        {
            return Task.Factory.StartNew(() =>
            {
                try
                {
                    SocketMessage sm = new SocketMessage(Request.GET_HDJCONTRACT_REQUEST, Id);
                    ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));
                    string recMsg = null;
                    lock (recivebuffer)
                    {
                        recLength = ClientSocket.Receive(recivebuffer);
                        recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                    }
                    string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);
                    
                    if (Msg[0] == Response.GET_HDJCONTRACT_SUCCESS.ToString())
                    {
                        HDJContract list = new HDJContract();
                        list = JsonConvert.DeserializeObject<HDJContract>(Msg[2]);

                        return list;
                    }
                    else
                    {
                        Logging.AddLog("查询会签单信息失败!");
                        return null;
                    }
                }
                catch
                {
                    Logging.AddLog("查询会签单信息失败(服务器连接中断)!");
                    return null;
                }
            });
        }
示例#21
0
         /// <summary>
         /// 根据项目简称ID获取项目名称
         /// </summary>
         /// <param name="categoryId"></param>
         /// <returns></returns>
         public List<ContractProject> QueryContractProject(int categoryId)
         {
             try
             {
                 SocketMessage sm = new SocketMessage(Request.QUERY_CATEGORY_PROJECT_REQUEST, categoryId);
                 ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                 recLength = ClientSocket.Receive(recivebuffer);
                 string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                 string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                 if (Msg[0] == Response.QUERY_CATEGORY_PROJECT_SUCCESS.ToString())
                 {
                     List<ContractProject> list = new List<ContractProject>();
                     list = JsonConvert.DeserializeObject<List<ContractProject>>(Msg[2]);

                     return list;
                 }
                 else
                 {
                     Logging.AddLog("项目名称查询失败!");
                     return null;
                 }
             }
             catch
             {
                 Logging.AddLog("项目名称查询失败(服务器连接中断)!");
                 return null;
             }
         }
示例#22
0
        ///// <summary>
        ///// 查询会签单信息
        ///// </summary>
        ///// <param name="Id"></param>
        ///// <returns></returns>
        //public HDJContract GetHDJContract(string Id)
        //{
        //        try
        //        {
        //            SocketMessage sm = new SocketMessage(Request.GET_HDJCONTRACT_REQUEST, Id);
        //            ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

        //            recLength = ClientSocket.Receive(recivebuffer);
        //            string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
        //            string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

        //            if (Msg[0] == Response.GET_HDJCONTRACT_SUCCESS.ToString())
        //            {
        //                HDJContract list = new HDJContract();
        //                list = JsonConvert.DeserializeObject<HDJContract>(Msg[2]);

        //                return list;
        //            }
        //            else
        //            {
        //                Logging.AddLog("查询会签单信息失败!");
        //                return null;
        //            }
        //        }
        //        catch
        //        {
        //            Logging.AddLog("查询会签单信息失败(服务器连接中断)!");
        //            return null;
        //        }
        //}
        
        /// <summary>
        /// 签单签字情况
        /// </summary>
        /// <param name="sd"></param>
        /// <returns></returns>
        public string SignDetail(SignatureDetail sd)
        {
            //return Task.Factory.StartNew(() =>
            {
                try
                {
                    SocketMessage sm = new SocketMessage(Request.INSERT_SIGN_DETAIL_REQUEST, sd);
                    ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                    recLength = ClientSocket.Receive(recivebuffer);
                    string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                    string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                    if (Msg[0] == Response.INSERT_SIGN_DETAIL_SUCCESS.ToString())
                    {
                        Logging.AddLog("签单签字成功!");
                    }
                    else
                    {
                        Logging.AddLog("签单签字失败!");
                    }
                    return Msg[0];
                }
                catch
                {
                    Logging.AddLog("签单签字失败(服务器连接中断)!");
                    return "服务器连接中断";
                }
            //});
            }
        }
示例#23
0
        /// <summary>
        /// 添加部门权限
        /// </summary>
        /// <param name="sdepartment"></param>
        /// <returns></returns>
        public string InsertSDepartment(SDepartment sdepartment)
        {
            try
            {
                SocketMessage sm = new SocketMessage(Request.INSERT_SDEPARTMENT_REQUEST, sdepartment);
                //scoket发送请求信息
                ClientSocket.Send(Encoding.UTF8.GetBytes(sm.Package));

                //scoket接收请求信息
                recLength = ClientSocket.Receive(recivebuffer);
                string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                if (Msg[0] == Response.INSERT_SDEPARTMENT_SUCCESS.ToString())
                {
                    Logging.AddLog("添加部门权限成功!");
                }
                else
                {
                    Logging.AddLog("添加部门权限失败!");
                }
                return Msg[0];
            }
            catch
            {
                Logging.AddLog("添加部门权限失败(服务器连接中断)!");
                return "添加失败";
            }
        }
示例#24
0
        /// <summary>
        /// 上传签字图片
        /// </summary>
        /// <param name="id"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public async Task UploadPicture(int id, string p)
        {
            await Task.Run(() =>
            {
                SocketMessage sm = new SocketMessage(Request.UPLOAD_PICTURE_REQUEST, id);

                //recLength = ClientSocket.Receive(recivebuffer);
                //string recMsg = Encoding.UTF8.GetString(recivebuffer, 0, recLength);
                //string[] Msg = recMsg.Split(SocketMessage.DEFAULT_SEPARATOR);

                //if (Msg[0] == Response.UPLOAD_PICTURE_SUCCESS.ToString())
                //{
                    Socket sendpicture = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    sendpicture.Connect(new IPEndPoint(IP, 6060));
                    FileStream fs = new FileStream(p, FileMode.OpenOrCreate, FileAccess.Read);
                    byte[] fssize = new byte[fs.Length];
                    BinaryReader reader = new BinaryReader(fs);
                    reader.Read(fssize, 0, fssize.Length - 1);
                    sendpicture.Send(Encoding.UTF8.GetBytes((sm.Package+"~").PadRight(50,'0')));
                    sendpicture.Send(fssize);
                    fs.Close();
                    sendpicture.Shutdown(System.Net.Sockets.SocketShutdown.Send);
                    sendpicture.Close();
                //}
            });
        }
示例#25
0
        /// <summary>
        /// 上传计划配额表
        /// </summary>
        /// <param name="search"></param>
        /// <param name="filepath"></param>
        /// <returns></returns>
        public async Task<bool> UploadRegularload(Search search, string filepath)
        {
            return await Task.Factory.StartNew(() =>
            {
                try
                {
                    /*FileInfo fileinfo = new FileInfo(filepath);
                    FileStream filestream = fileinfo.OpenRead();
                    //包的大小
                    int packetSize = 100000;
                    //包的数量
                    int packetCount = (int)(filestream.Length / ((long)packetSize));
                    //最后一个包的大小
                    int LastDataPacket = (int)(filestream.Length - ((long)(packetSize * packetCount)));
                    
                    SocketMessage sm = new SocketMessage(Request.UPLOAD_REGULARLOAD_REQUEST, search);
                    Socket upload = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    upload.Connect(new IPEndPoint(IP, 6060));
                    upload.Send(Encoding.UTF8.GetBytes((sm.Package + "~").PadRight(300, '0')));
                    byte[] data = new byte[packetSize];
                    for (int i = 0; i < packetCount; i++)
                    {
                        filestream.Read(data, 0, data.Length);
                        SendVarData(upload, data);
                    }
                    if (LastDataPacket != 0)
                    {
                        data = new byte[LastDataPacket];
                        filestream.Read(data, 0, data.Length);
                        SendVarData(upload, data);
                    }*/
                    SocketMessage sm = new SocketMessage(Request.UPLOAD_REGULARLOAD_REQUEST, search);
                    Socket upload = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    upload.Connect(new IPEndPoint(IP, 6060));

                    FileStream fs = new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Read);
                    byte[] fssize = new byte[fs.Length];
                    BinaryReader reader = new BinaryReader(fs);
                    reader.Read(fssize, 0, fssize.Length - 1);
                    upload.Send(Encoding.UTF8.GetBytes((sm.Package + "~").PadRight(300, '0')));
                    upload.Send(fssize);
                    fs.Close();
                    upload.Shutdown(System.Net.Sockets.SocketShutdown.Send);
                    upload.Close();

                    return true;
                }
                catch
                {
                    return false;
                }
            });
        }