Exemplo n.º 1
0
        private void ParsInfo(Zillow zillow)
        {
            Thread thread = new Thread(() =>
            {
                LinkParser linkParser;
                ReqParametres reqParametres;
                do
                {
                    //Парсим предварительную ссылку
                    reqParametres = new ReqParametres(zillow.URL);
                    reqParametres.SetUserAgent(Useragents.GetNewUseragent());
                    reqParametres.SetProxy();
                    linkParser   = new LinkParser(reqParametres.Request);
                    SavedCookies = linkParser.Cookies;
                } while (isCaptcha(linkParser.Data));
                string newLink = linkParser.Data.ParsFromTo("<link rel=\"canonical\" href=\"", "\"");
                //Проверяем на неверную ссылку
                if (newLink.Contains("https://www.zillow.com/homes/for_sale/"))
                {
                    zillow.Status = "No such adress";
                }
                else
                {
                    zillow.URL = newLink;

                    do
                    {
                        reqParametres = new ReqParametres(zillow.URL);
                        reqParametres.SetUserAgent(Useragents.GetNewUseragent());
                        reqParametres.SetProxy();
                        linkParser = new LinkParser(reqParametres.Request);
                    } while (isCaptcha(linkParser.Data));
                    zillow.Status = CheckOnStatus(linkParser.Data.ToLower()).Replace("<span tabindex=\"0\" role=\"button\"><span class=\"zsg-tooltip-launch_keyword\">", "")
                                    .Replace("<Span Tabindex=\"0\" Role=\"Button\"><Span Class=\"Zsg-Tooltip-Launch_Keyword\">", "");
                    if (zillow.Status.Equals("Undefined"))
                    {
                        DebugBox.WriteLine(linkParser.Data);
                    }
                    else
                    {
                        //Zestimate set
                        List <string> rawZestimate = linkParser.Data.ParsRegex("Zestimate<sup>®</sup></span></span>(.*?)\\$([0-9,./a-zA-Z]+)<", 2);
                        if (rawZestimate.Count != 0)
                        {
                            zillow.Zestimate = "$" + rawZestimate[0];
                        }
                        zillow.SoldPrice = CheckPrice(linkParser.Data);
                    }
                    SavedCookies = linkParser.Cookies;
                }
                threadCount--;
                progress++;
                DebugBox.WriteLine($"Обработано ссылок: {progress} из {results.Count}.");
                double val = 100.0f / results.Count * progress;
                WorkProgress.SetValue(val);
            });

            thread.IsBackground = true;
            thread.Start();
        }
Exemplo n.º 2
0
        private void AppendProgress(Jp2KrTranslationVM tvm)
        {
            var control   = new WorkProgress(tvm);
            var container = new BlockUIContainer(control);

            WithAutoScroll(() => TbLog.Document.Blocks.Add(container));
        }
 void Start()
 {
     //myRenderers = GetComponentsInChildren<MeshRenderer>();
     ui           = GetComponent <WorkProgress>();
     interactions = GetComponents <Interaction>();
     household    = FindObjectOfType <Household>();
     ps           = GetComponentInChildren <ParticleSystem>();
     ps?.gameObject.SetActive(false);
 }
Exemplo n.º 4
0
        public WorkProgress SaveWorkProgress(WorkProgressViewModel workProg)
        {
            WorkProgress wProg = null;

            if (workProg.ProgId > 0)
            {
                wProg = this.GetWorkProgress(workProg.ProgId);
            }


            //不是创建人只能新增不能修改
            if (wProg == null ||
                wProg.Creator != _identity.Claims.Where(c => c.Type == "name").FirstOrDefault().Value)
            {
                BizSteps step = _context.BizSteps.Include("BizItem").Where(s => s.StepId == workProg.StepId).FirstOrDefault();

                wProg        = new WorkProgress();
                wProg.WoId   = workProg.WoId;
                wProg.ItemId = step.BizItem.ItemId;
                wProg.StepId = step.StepId;
                _context.WorkProgress.Add(wProg);
            }


            wProg.CompletedTime      = workProg.CompletedTime;
            wProg.ResultDesc         = workProg.ResultDesc;
            wProg.AdvanceExpenditure = workProg.AdvanceExpenditure;
            wProg.CreateTime         = DateTime.Now;
            wProg.Creator            = _identity.Claims.Where(c => c.Type == "name").FirstOrDefault().Value;
            wProg.SortIndex          = workProg.SortIndex;
            wProg.IsSuccess          = workProg.IsSuccess;
            //重算代垫费用
            WorkOrder wOrder = _context.WorkOrders.Include("WorkProgresses").Where(wo => wo.WoId == wProg.WoId).First();

            wOrder.AdvanceExpenditure = wOrder.WorkProgresses.Sum(p => p.AdvanceExpenditure);
            wOrder.State = WorkOrderState.InProcess;

            if (!string.IsNullOrEmpty(workProg.Url))
            {
                ProgressImage pi = new ProgressImage();
                if (wProg.Images.Count > 0)
                {
                    pi = wProg.Images.FirstOrDefault();
                }
                else
                {
                    wProg.Images.Add(pi);
                }
                pi.AliyunKey    = workProg.FileName;
                pi.Url          = workProg.Url;
                pi.Expiration   = DateTime.Now.AddYears(5);
                pi.WorkProgress = wProg;
            }

            _context.SaveChanges();
            return(wProg);
        }
Exemplo n.º 5
0
    public void CallBackEndWork()
    {
        workProgress = WorkProgress.Is_Done;


        //make money
        long earnedGold = workList[currentIndex].gold * playerData.playerTier;

        MasterManager.ManagerGlobalData.GetEnvData().gold += earnedGold;
        MasterManager.ManagerGlobalData.SaveEnvData();

        //reduce stamina
        //ListDataInfo playerData = MasterManager.ManagerGlobalData.GetPlayerDataInfo();
        playerData.statsList[0].Stamina -= (short)(workList[currentIndex].stamina * playerData.playerTier);


        MasterManager.ManagerPopup.ShowMessageBox("Hey!", "You made " + earnedGold.ToString() + " gold", Constants.PopupType.POPUP_SYSTEM);

        //update player ui
        TownManager.Instance.UpdatePlayerUI();

        //take out the work from the list
        workList.RemoveAt(currentIndex);
        playerData.workIndexList.RemoveAt(currentIndex);
        currentIndex = 0;

        //save player data
        MasterManager.ManagerGlobalData.SavePlayerData();

        //only if there is still work availiable in the work list
        if (workList.Count > 0)
        {
            SetCurrentWork();
        }
        else
        {
            Current.GetComponentInChildren <WorkWindow>().SetWorkWindow("", "", "");
            goldText.text    = "";
            staminaText.text = "";
            TimeText.text    = "";
        }

        if (bReservedResetWork)
        {
            ResetWork();
            bReservedResetWork = false;
        }

        workProgress = WorkProgress.Is_Ready;
    }
Exemplo n.º 6
0
    public void OnOK()
    {
        //check stamina
        if (playerData.GetActualStats().Stamina < workList[currentIndex].stamina * playerData.playerTier)
        {
            MasterManager.ManagerPopup.ShowMessageBox("Hey!", "Not Enough Stamina", Constants.PopupType.POPUP_NO);
        }
        else
        {
            TownManager.Instance.CloseCurrentWindow(true, CallBackEndWork, workList[currentIndex].turn);
            workProgress = WorkProgress.Is_Working;
        }

        workPopup.SetActive(false);
    }
Exemplo n.º 7
0
        /// <summary>
        /// 开始
        /// </summary>
        /// <param name="doWork"></param>
        /// <param name="workDone"></param>
        /// <param name="workProgress"></param>
        private void StartInternal(DoWork doWork, WorkDone workDone, WorkProgress workProgress = null)
        {
            m_worker       = new AsyncHelperWorker(doWork);
            m_asyncManager = new AsyncManager <object, object>(Guid.NewGuid().ToString(), m_worker);

            m_workDone = workDone;
            m_asyncManager.WorkerDone += new EventHandler <WorkerDoneEventArgs <object> >(asyncManager_WorkerDone);

            if (workProgress != null)
            {
                m_workProgress = workProgress;
                m_asyncManager.WorkerProgress += new EventHandler <WorkerProgressEventArgs <object> >(m_asyncManager_WorkerProgress);
            }

            m_asyncManager.StartWorker(SystemConfiguration.UseMultiThread);
        }
Exemplo n.º 8
0
        private void GenerateButton_Click(object sender, RoutedEventArgs e)
        {
            IGenerator gen = AssemblerInfo.GetGenerator(mSelectedAssemblerId);

            if (gen == null)
            {
                Debug.WriteLine("Unable to get generator for " + mSelectedAssemblerId);
                return;
            }
            gen.Configure(mProject, mWorkDirectory, mBaseFileName,
                          AssemblerVersionCache.GetVersion(mSelectedAssemblerId), AppSettings.Global);

            GenWorker    gw  = new GenWorker(gen);
            WorkProgress dlg = new WorkProgress(this, gw, false);

            dlg.ShowDialog();
            //Debug.WriteLine("Dialog returned: " + dlg.DialogResult);

            GenerationResults res = gw.Results;

            if (res == null)
            {
                // error or cancelation; errors already reported
                return;
            }

            ResetElements();
            mGenerationResults = res;
            previewFileComboBox.Items.Clear();
            foreach (string str in res.PathNames)
            {
                previewFileComboBox.Items.Add(new ComboPath(str));
            }
            previewFileComboBox.SelectedIndex = 0;      // should trigger update

            UpdateAssemblerControls();
        }
Exemplo n.º 9
0
    void Awake()
    {
        playerData = MasterManager.ManagerGlobalData.GetPlayerDataInfo();

        //only at once
        if (TownManager.Instance.IsitFirstPlay())
        {
            ResetWork();
        }
        else
        {
            ListWorkInfo allWorkInfo = MasterManager.ManagerGlobalData.GetAllWorkData();
            for (int i = 0; i < playerData.workIndexList.Count; ++i)
            {
                int actualIndex = playerData.workIndexList[i];
                workList.Add(allWorkInfo.workList[actualIndex]);
            }

            //only if there is still work availiable in the work list
            if (workList.Count > 0)
            {
                SetCurrentWork();
            }
            else
            {
                Current.GetComponentInChildren <WorkWindow>().SetWorkWindow("", "", "");
                goldText.text    = "";
                staminaText.text = "";
                TimeText.text    = "";
            }
        }

        bMoving            = false;
        bReservedResetWork = false;
        workProgress       = WorkProgress.Is_Ready;
    }
Exemplo n.º 10
0
        private void RunAssemblerButton_Click(object sender, RoutedEventArgs e)
        {
            IAssembler asm = AssemblerInfo.GetAssembler(mSelectedAssemblerId);

            if (asm == null)
            {
                Debug.WriteLine("Unable to get assembler for " + mSelectedAssemblerId);
                return;
            }

            asm.Configure(mGenerationResults, mWorkDirectory);

            AsmWorker    aw  = new AsmWorker(asm);
            WorkProgress dlg = new WorkProgress(this, aw, true);

            dlg.ShowDialog();
            //Debug.WriteLine("Dialog returned: " + dlg.DialogResult);
            if (dlg.DialogResult != true)
            {
                // Canceled, or failed to even run the assembler.
                return;
            }

            AssemblerResults results = aw.Results;

            if (results == null)
            {
                Debug.WriteLine("Dialog returned OK, but no assembler results found");
                Debug.Assert(false);
                return;
            }

            StringBuilder sb =
                new StringBuilder(results.Stdout.Length + results.Stderr.Length + 200);

            sb.Append(results.CommandLine);
            sb.Append("\r\n");
            sb.AppendFormat("ExitCode={0} - ", results.ExitCode);
            if (results.ExitCode == 0)
            {
                FileInfo fi = new FileInfo(results.OutputPathName);
                if (!fi.Exists)
                {
                    MessageBox.Show(this, Res.Strings.ASM_OUTPUT_NOT_FOUND,
                                    Res.Strings.ASM_MISMATCH_CAPTION,
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                    sb.Append(Res.Strings.ASM_MATCH_FAILURE);
                }
                else if (!CommonUtil.FileUtil.CompareBinaryFile(mProject.FileData,
                                                                results.OutputPathName, out int offset, out byte fileVal))
                {
                    if (fi.Length != mProject.FileData.Length &&
                        offset == fi.Length || offset == mProject.FileData.Length)
                    {
                        // The files matched up to the point where one ended.
                        string msg = string.Format(Res.Strings.ASM_MISMATCH_LENGTH_FMT,
                                                   fi.Length, mProject.FileData.Length);
                        MessageBox.Show(msg, Res.Strings.ASM_MISMATCH_CAPTION,
                                        MessageBoxButton.OK, MessageBoxImage.Error);
                        sb.Append(msg);
                    }
                    else
                    {
                        string msg = string.Format(Res.Strings.ASM_MISMATCH_DATA_FMT,
                                                   offset, fileVal, mProject.FileData[offset]);
                        MessageBox.Show(msg, Res.Strings.ASM_MISMATCH_CAPTION,
                                        MessageBoxButton.OK, MessageBoxImage.Error);
                        sb.Append(msg);
                    }
                }
                else
                {
                    sb.Append(Res.Strings.ASM_MATCH_SUCCESS);
                }
            }
Exemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="doWork"></param>
 /// <param name="workDone"></param>
 /// <param name="workProgress"></param>
 public AsyncHelper(DoWork doWork, WorkDone workDone, WorkProgress workProgress)
 {
     StartInternal(doWork, workDone, workProgress);
 }
Exemplo n.º 12
0
        public WorkOrder SaveWorkOrder(WorkOrderViewModel workOrder)
        {
            WorkOrder wo = null;

            if (workOrder.WoId > 0)
            {
                wo = this.GetWorkOrder(workOrder.WoId);
            }
            else
            {
                wo            = new WorkOrder();
                wo.CreateTime = DateTime.Now;
                wo.Creator    = _identity.GetUserName();
                wo.State      = WorkOrderState.New;
            }

            //业务项目
            WorkOrderItem[] woItems = wo.WorkOrderItems.ToArray();
            for (int i = woItems.Count() - 1; i >= 0; i--)
            {
                //先删除旧记录
                wo.WorkOrderItems.Remove(woItems[i]);
            }
            string[] items = workOrder.BizItemIds.Split(',');
            foreach (string i in items)
            {
                //添加关联项目
                WorkOrderItem woi = new WorkOrderItem();
                woi.WorkOrder         = wo;
                woi.BizItem           = _setting.GetBizItem(Convert.ToInt32(i));
                wo.CommercialExpense += woi.BizItem.ServicePrice;
                wo.WorkOrderItems.Add(woi);

                //生成进度步骤
                foreach (BizSteps s in woi.BizItem.BizSteps)
                {
                    WorkProgress p = new WorkProgress();
                    p.WorkOrder          = wo;
                    p.BizItem            = woi.BizItem;
                    p.BizStep            = s;
                    p.CompletedTime      = null;
                    p.ResultDesc         = null;
                    p.AdvanceExpenditure = 0;
                    p.Creator            = _identity.GetUserName();
                    p.CreateTime         = DateTime.Now;
                    wo.WorkProgresses.Add(p);
                }
            }

            //校验客户编号的有效性
            wo.Customer           = _customer.GetCustomer(workOrder.CusId);
            wo.ContractTime       = workOrder.ContractTime;
            wo.Remark             = workOrder.Remark;
            wo.BizManager         = workOrder.BizManager;
            wo.BizOperations      = workOrder.BizOperations;
            wo.Recommend          = workOrder.Recommend;
            wo.PreferentialAmount = workOrder.PreferentialAmount;
            wo.Priority           = (WorkOrderPriority)workOrder.Priority;
            wo.FinishTime         = workOrder.FinishTime;

            _context.WorkOrders.AddOrUpdate(wo);
            _context.SaveChanges();

            return(wo);
        }