예제 #1
0
        public string validOrder(string orderName)
        {
            string rtn = "";

            if (orderName.IndexOf("_") > 0)
            {
                string[] nameCode = orderName.Split('_');
                if (nameCode.Length == 2)
                {
                    string code = nameCode[1];
                    verifyCode = code;
                    try
                    {
                        string strOrder = webService.isExistOrder(code, CurrentUser.UserName);
                        if (strOrder.Length > 2)
                        {
                            vjList = getValidate(strOrder);
                            if (vjList.name.Length > 0)
                            {
                                return(rtn);
                            }
                            string pType = vjList.peopleType;
                        }
                        else if (strOrder == "-1")
                        {
                            rtn = "验证码不存在,或者被使用,";
                        }
                        else if (strOrder == "-2")
                        {
                            rtn = "门店用户未设置所属门店,";
                        }
                        else if (strOrder == "-3")
                        {
                            rtn = "订单预约门店与使用门店不同,";
                        }
                        else if (strOrder == "-4")
                        {
                            rtn = "订单状态不可用,";
                        }
                    }
                    catch (Exception ex)
                    {
                        rtn = "验证时出错";
                        string er = ex.ToString();
                        LogHelper.WriteLog(ex.ToString());
                    }
                }
                else
                {
                    rtn = "验证码录入有误,";
                }
            }
            else
            {
                rtn = "验证码录入有误,";
            }
            return(rtn);
        }
예제 #2
0
        private ValidateJson getValidate(string strJson)
        {
            ValidateJson vj = new ValidateJson();

            try
            {
                vj = JsonConvert.DeserializeObject <ValidateJson>(strJson);
            }
            catch (Exception ex)
            {
                string ss = ex.ToString();
            }
            return(vj);
        }
예제 #3
0
        private void uploadInfo()
        {
            string code      = "";
            bool   isCorrect = false;
            string errormsg  = "";

            if (File.Exists(testFile))
            {
                if (File.Exists(sourceFile))
                {
                    File.Delete(sourceFile);
                }
                File.Copy(testFile, sourceFile);
                FileInfo fileInfo = new FileInfo(sourceFile);

                string timeStr = ReadAppSetting("ChangeTime");// ConfigurationManager.AppSettings["ChangeTime"].ToString();
                //文件没有更新,不处理
                if (timeStr.Length == 0)
                {
                    SetValue("ChangeTime", fileInfo.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"));
                    File.Delete(sourceFile);
                    return;
                }

                DateTime dtNow = DateTime.Parse(fileInfo.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"));
                DateTime dtOld = DateTime.Parse(ReadAppSetting("ChangeTime"));

                //有最新文件,开始上传数据
                if (DateTime.Compare(dtNow, dtOld) > 0)
                {
                    latestTime = dtNow.ToString("yyyy-MM-dd HH:mm:ss");
                    SetValue("ChangeTime", latestTime);
                    Excel.ApplicationClass excel = new Microsoft.Office.Interop.Excel.ApplicationClass();
                    //MessageBox.Show(excel.Version);
                    excel.Visible = false;
                    excel.Workbooks.Open(sourceFile, Type.Missing, Type.Missing, Type.Missing, "halleluja", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);


                    Excel.Worksheet ws   = (Excel.Worksheet)excel.Worksheets[2];
                    string          name = ((Excel.Range)ws.Cells[3, 3]).Text.ToString();
                    sourceFileName = name;
                    excel.Quit();

                    IntPtr t = new IntPtr(excel.Hwnd);
                    int    k = 0;
                    GetWindowThreadProcessId(t, out k);
                    System.Diagnostics.Process p = System.Diagnostics.Process.GetProcessById(k);
                    p.Kill();

                    if (name.IndexOf("_") > 0)
                    {
                        string[] nameCode = name.Split('_');
                        if (nameCode.Length == 2)
                        {
                            code       = nameCode[1].Trim();
                            verifyCode = code;
                            try
                            {
                                string strOrder = webService.isExistOrder(code, CurrentUser.UserName);
                                if (strOrder.Length > 2)
                                {
                                    vjList = getValidate(strOrder);
                                    if (vjList.name.Length > 0)
                                    {
                                        isCorrect = true;
                                    }
                                    string pType = vjList.peopleType;
                                    //pType = "1";
                                    if (pType == "1")
                                    {
                                        isAdult = false;
                                    }
                                    else
                                    {
                                        isAdult = true;
                                    }
                                }
                                else if (strOrder == "-1")
                                {
                                    errormsg = "验证码不存在,或者被使用,";
                                }
                                else if (strOrder == "-2")
                                {
                                    errormsg = "门店用户未设置所属门店,";
                                }
                                else if (strOrder == "-3")
                                {
                                    errormsg = "订单预约门店与使用门店不同,";
                                }
                                else if (strOrder == "-4")
                                {
                                    errormsg = "订单状态不可用,";
                                }
                            }
                            catch (Exception ex)
                            {
                                string er = ex.ToString();
                            }
                        }
                        else
                        {
                            errormsg = "验证码录入有误,";
                        }
                    }
                    else
                    {
                        errormsg = "验证码录入有误,";
                    }
                }
                //没有更新文件
                else
                {
                    File.Delete(sourceFile);
                    WriteLog("没有更新文件,数据没有上传!");
                    return;
                }

                //上传文件到服务器
                //verifyCode = "hahahaha";
                FTPUpLoad();

                //有更新文件,但是文件有问题
                if (!isCorrect)
                {
                    File.Delete(sourceFile);
                    //SetValue("ChangeTime", latestTime);
                    WriteLog(sourceFileName + "-" + errormsg + "文件存在问题,数据没有上传!");
                    MessageBox.Show(sourceFileName + "-" + errormsg + "数据没有上传!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                //SetValue("ChangeTime", latestTime);
                WriteLog("开始上传数据");
                //copyTemp();
                copyStream();
                //上传数据
                Thread thdSub = new Thread(new ThreadStart(ThreadFun));
                thdSub.Start();
            }
        }
예제 #4
0
        public bool uploadInfo()
        {
            bool   rtn       = false;
            string code      = "";
            bool   isCorrect = false;
            string errormsg  = "";
            string name      = "";

            if (File.Exists(testFile))
            {
                if (File.Exists(sourceFile))
                {
                    File.Delete(sourceFile);
                }
                File.Copy(testFile, sourceFile);
                FileInfo fileInfo = new FileInfo(sourceFile);

                //有最新文件,开始上传数据
                //先检查数据源中的校验码是否正确
                Excel.ApplicationClass excel = new Excel.ApplicationClass();
                //MessageBox.Show(excel.Version);
                excel.Visible = false;
                excel.Workbooks.Open(sourceFile, Type.Missing, Type.Missing, Type.Missing, "halleluja", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);


                Excel.Worksheet ws = (Excel.Worksheet)excel.Worksheets[2];
                name           = ((Excel.Range)ws.Cells[3, 3]).Text.ToString();
                sourceFileName = name;
                excel.Quit();

                IntPtr t = new IntPtr(excel.Hwnd);
                int    k = 0;
                GetWindowThreadProcessId(t, out k);
                System.Diagnostics.Process p = System.Diagnostics.Process.GetProcessById(k);
                p.Kill();

                if (name.IndexOf("_") > 0)
                {
                    string[] nameCode = name.Split('_');
                    if (nameCode.Length == 2)
                    {
                        code       = nameCode[1];
                        verifyCode = code;
                        try
                        {
                            string strOrder = webService.isExistOrder(code, CurrentUser.UserName);
                            if (strOrder.Length > 2)
                            {
                                vjList = getValidate(strOrder);
                                if (vjList.name.Length > 0)
                                {
                                    isCorrect = true;
                                }
                                string pType = vjList.peopleType;
                                //if (pType == "1")
                                //{
                                //    isAdult = false;
                                //}
                                //else
                                //{
                                //    isAdult = true;
                                //}
                            }
                            else if (strOrder == "-1")
                            {
                                errormsg = "验证码不存在,或者被使用,";
                            }
                            else if (strOrder == "-2")
                            {
                                errormsg = "门店用户未设置所属门店,";
                            }
                            else if (strOrder == "-3")
                            {
                                errormsg = "订单预约门店与使用门店不同,";
                            }
                            else if (strOrder == "-4")
                            {
                                errormsg = "订单状态不可用,";
                            }
                        }
                        catch (Exception ex)
                        {
                            string er = ex.ToString();
                            LogHelper.WriteLog(ex.ToString());
                        }
                    }
                    else
                    {
                        errormsg = "验证码录入有误,";
                    }
                }
                else
                {
                    errormsg = "验证码录入有误,";
                }


                //上传文件到服务器
                //verifyCode = "hahahaha";
                FTPUpLoad();

                //有更新文件,但是文件有问题
                if (!isCorrect)
                {
                    File.Delete(sourceFile);
                    //SetValue("ChangeTime", latestTime);
                    LogHelper.WriteLog(sourceFileName + "-" + errormsg + "文件存在问题,云端处理数据失败!");
                    //XtraMessageBox.Show(sourceFileName + "-" + errormsg + "云端处理数据失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }
                //SetValue("ChangeTime", latestTime);
                LogHelper.WriteLog("开始云端处理数据");
                //copyTemp();
                copyStream();
                //上传数据
                //Thread thdSub = new Thread(new ThreadStart(ThreadFun));
                //thdSub.Start();
                rtn = ThreadFun();
            }
            return(rtn);
        }