Пример #1
0
/**
 *
 * TCP 服务器接收文件时发生
 *
 * */
        public static bool RcvFileFromClient(Socket client)
        {
            /*接受文件头*/

            //请求头
            FileSendOnNet     fson  = RcvOperationHeader_EXT(client);
            CommunicationType cType = fson.GetCommunicationType();

            if (cType == CommunicationType.Send2Print)
            {
                //打印文件
                SendServerPermission(client);
                RcvFileRawData2Print(client);
            }
            else if (cType == CommunicationType.Send2Receive)
            {
                //发送文件
                SendServerPermission(client);
                RcvFileRawData2Save(client);
            }
            else if (cType == CommunicationType.GetPrinterListXml)
            {
                //客户获取打印机列表
                //发送本地打印机列表XML文件
                SendServerPermission(client);
                SendPrinterList(client);
            }
            else if (cType == CommunicationType.Send2PrintNoPay)
            {
                //打印文件--未付款
                //返回客户端,订单号。
                SendServerPermission(client);
                //接受文件到本地磁盘
                RcvFileRawData2Save_NoPay(client);
                //PrintRecord pp = new PrintRecord();
                //pp.WriteRecord2Disk(file);
            }
            else if (cType == CommunicationType.GetPriceById)
            {
                //客户获取价格
                //
                SendServerPermission(client);
                SendPrinterPrice(client, fson);
                //String id fson.GetProperty("orderid_suffix","");

                //SendPrinterList(client);
            }
            else
            {
                //Debug.Assert(false);
            }

            /*返回客户端权限*/
            return(true);
        }