Пример #1
0
        private void AddSequence()
        {
            SequenceService service  = new SequenceService();
            Sequence        sequence = service.GenerateNextSequence(Sequences);

            OrderObservableList.AddSorted(Sequences, sequence);
        }
Пример #2
0
        public HttpResponseMessage SelectByProjectId(int actId)
        {
            ItemsResponse <Sequence> response = new ItemsResponse <Sequence>();

            response.Items = SequenceService.SelectByActId(actId);
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Пример #3
0
        public async Task <int> insert(DbConnectionService dbcs)
        {
            string sql = "INSERT INTO ArticleContents VALUES(:Id, :FileName, :ContentType, :ArticleId, :CreatedAt, :UpdatedAt)";

            SequenceService seq = new SequenceService();
            var             Id  = seq.getNextVal(SequenceService.seqType.ArticleContents);
            var             now = DateTime.Now;

            var result = await dbcs.GetConnection().ExecuteAsync(sql, new
            {
                Id = Id
                ,
                FileName = this.FileName
                ,
                ContentType = this.ContentType
                ,
                ArticleId = this.ArticleId
                ,
                CreatedAt = now
                ,
                UpdatedAt = now
            }, dbcs.GetTransaction());;

            return(result);
        }
Пример #4
0
        public HttpResponseMessage SelectById(int id)
        {
            ItemResponse <Sequence> response = new ItemResponse <Sequence>();

            response.Item = SequenceService.SelectById(id);
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Пример #5
0
        public HttpResponseMessage Delete(int id)
        {
            SequenceService.Delete(id);
            SuccessResponse response = new SuccessResponse();

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void filePhoto_FileSelected(object sender, EventArgs e)
        {
            if (filePhoto.HasFile)
            {
                var fileSuffix = filePhoto.ShortFileName.Substring(filePhoto.ShortFileName.LastIndexOf('.'));

                var sequence = SequenceService.CreateSequence("LH", CurrentUser.AccountComId);

                var fileName = sequence + fileSuffix;

                var uploadpath = Config.GetUploadpath();

                var tempPath = (string.Format(@"{0}/temp/{1}/", uploadpath, DateTime.Now.ToString("yyyy-MM-dd"))); //

                if (!DirFile.XFileExists(Server.MapPath(tempPath)))
                {
                    DirFile.XCreateDir(Server.MapPath(tempPath));
                }

                filePhoto.SaveAs(Server.MapPath(tempPath + fileName));

                hfdImage.Text = tempPath + fileName;

                // 清空文件上传组件
                filePhoto.Reset();
            }
        }
Пример #7
0
 public SchedulesController()
 {
     _projectService  = new ProjectService(new GhostRunnerContext(ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString));
     _scheduleService = new ScheduleService(new GhostRunnerContext(ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString));
     _sequenceService = new SequenceService(new GhostRunnerContext(ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString));
     _scriptService   = new ScriptService(new GhostRunnerContext(ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString));
 }
Пример #8
0
        /// <summary>
        ///     加载页面数据
        /// </summary>
        private void LoadData()
        {
            switch (Actions)
            {
            case WebAction.Add:
                Region1.Title = "添加盘盈单";

                txtKeyId.Text = SequenceService.CreateSequence("TM", CurrentUser.AccountComId);
                var temp = new LHStockIn
                {
                    KeyId = txtKeyId.Text,

                    FFlag = 1,

                    FDeleteFlag = 1,

                    //盘盈单
                    FType = Convert.ToInt32(GasEnumBill.Profit),

                    CreateBy = CurrentUser.AccountName,

                    FDate = txtFDate.SelectedDate,

                    FCompanyId = CurrentUser.AccountComId,

                    FStatus = Convert.ToInt32(GasEnumBillStauts.Add),

                    FProgress = Convert.ToInt32(GasEnumBillStauts.Add),
                };

                //临时写入单据
                StockInService.Add(temp);


                var summary = new JObject
                {
                    { "FItemCode", "合计" },
                    { "FQty", 0 },
                    { "FAmount", 0 }
                };

                Grid1.SummaryData = summary;

                break;

            case WebAction.Edit:
                Region1.Title = "编辑盘盈单";

                txtKeyId.Text = KeyId;
                if (StockIn != null)
                {
                    txtFMemo.Text          = StockIn.FMemo;
                    ddlFCate.SelectedValue = StockIn.FCate;

                    BindDataGrid();
                }
                break;
            }
        }
Пример #9
0
        /// <summary>
        ///     提交添加
        /// </summary>
        private bool SubmintAdd()
        {
            var order = FKOrderService.Where(p => p.keyId == txtKeyId.Text.Trim() && p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault();

            if (order != null)
            {
                order.FCode = txtFCode.Text;
                order.FName = tbxFCustomer.Text;
                //--------------------------------------------------
                order.FDeleteFlag = 0;
                order.FMemo       = txtFMemo.Text.Trim();
                order.CreateBy    = CurrentUser.AccountName;
                order.FDate       = txtFDate.SelectedDate;

                var parms = new Dictionary <string, object>();
                parms.Clear();

                parms.Add("@KeyId", order.keyId);
                parms.Add("@companyId", CurrentUser.AccountComId);
                var amt =
                    Convert.ToDecimal(SqlService.ExecuteProcedureCommand("proc_FKOrderAmt", parms).Tables[0].Rows[0][0]);

                order.FAmount = amt;

                FKOrderService.SaveChanges();

                if (txtKeyId.Text.Contains("TM"))
                {
                    //单据号问题
                    string newKeyId   = SequenceService.CreateSequence(Convert.ToDateTime(txtFDate.SelectedDate), "NF", CurrentUser.AccountComId);
                    var    orderParms = new Dictionary <string, object>();
                    orderParms.Clear();
                    orderParms.Add("@oldKeyId", txtKeyId.Text);
                    orderParms.Add("@newKeyId", newKeyId);
                    orderParms.Add("@Bill", "19");
                    orderParms.Add("@companyId", CurrentUser.AccountComId);

                    SqlService.ExecuteProcedureCommand("proc_num", orderParms);
                    txtKeyId.Text = newKeyId;

                    //新增日志
                    var billStatus = new LHBillStatus
                    {
                        KeyId       = newKeyId,
                        FCompanyId  = CurrentUser.AccountComId,
                        FActionName = "新增",
                        FDate       = DateTime.Now,
                        FDeptId     = CurrentUser.AccountOrgId,
                        FOperator   = CurrentUser.AccountName,
                        FMemo       = String.Format("单据号{0},{1}新增现金费用单据。", newKeyId, CurrentUser.AccountName)
                    };
                    GasHelper.AddBillStatus(billStatus);
                }

                return(true);
            }

            return(false);
        }
Пример #10
0
        /// <summary>
        ///     加载页面数据
        /// </summary>
        private void LoadData()
        {
            switch (Actions)
            {
            case WebAction.Add:
                txtKeyId.Text = SequenceService.CreateSequence("TM", CurrentUser.AccountComId);
                Region3.Title = "调整客户代码期初占用钢瓶单";

                var temp = new LHInitMonth
                {
                    KeyId = txtKeyId.Text,

                    FFlag = 1,

                    FDeleteFlag = 1,

                    //调整客户代码期初占用钢瓶单
                    FType = Convert.ToInt32(GasEnumBill.ChangeAccount),

                    CreateBy = CurrentUser.AccountName,

                    FDate = txtFDate.SelectedDate,

                    FCompanyId = CurrentUser.AccountComId,

                    FStatus = Convert.ToInt32(GasEnumBillStauts.Add),
                };

                //临时写入单据
                InitMonthServie.Add(temp);

                //合计
                //var summary = new JObject
                //{
                //    {"FItemCode", "合计"},
                //    {"FQty", 0},
                //};

                //Grid1.SummaryData = summary;

                break;

            case WebAction.Edit:
                txtKeyId.Text = KeyId;
                Region3.Title = "编辑调整客户代码期初占用钢瓶单";

                if (StockOut != null)
                {
                    WebControlHandler.BindObjectToControls(StockOut, SimpleForm1);
                    txtFDate.SelectedDate = StockOut.FDate;
                    tbxFCustomer.Text     = StockOut.FName;
                    txtFAmount.Text       = StockOut.FAmount.ToString();

                    BindDataGrid();
                }
                break;
            }
        }
Пример #11
0
        /// <summary>
        ///     加载页面数据
        /// </summary>
        private void LoadData()
        {
            switch (Actions)
            {
            case WebAction.Add:
                txtKeyId.Text = SequenceService.CreateSequence("TM", CurrentUser.AccountComId);
                Region3.Title = "添加送货提成单";

                var temp = new LHDispatchCommission
                {
                    KeyId = txtKeyId.Text,

                    FFlag = 1,

                    FDeleteFlag = 1,

                    //送货提成单
                    FType = Convert.ToInt32(GasEnumBill.DispatchCommission),

                    CreateBy = CurrentUser.AccountName,

                    FDate = txtFDate.SelectedDate,

                    FCompanyId = CurrentUser.AccountComId,

                    FStatus = Convert.ToInt32(GasEnumBillStauts.Add),
                };

                //临时写入单据
                DispatchCommissionService.Add(temp);

                //合计
                var summary = new JObject
                {
                    { "FItemCode", "合计" },
                    { "FQty", 0 },
                    { "FAmount", 0 }
                };

                Grid1.SummaryData = summary;

                break;

            case WebAction.Edit:
                txtKeyId.Text = KeyId;
                Region3.Title = "编辑送货提成单";

                if (StockOut != null)
                {
                    WebControlHandler.BindObjectToControls(StockOut, SimpleForm1);
                    txtFDate.SelectedDate = StockOut.FDate;

                    BindDataGrid();
                }
                break;
            }
        }
Пример #12
0
        /// <summary>
        ///     提交添加
        /// </summary>
        private bool SubmintAdd()
        {
            var stock = StockInService.Where(p => p.KeyId == txtKeyId.Text.Trim()).FirstOrDefault();

            if (stock != null)
            {
                ModifiedGrid();

                stock.FCompanyId         = CurrentUser.AccountComId;
                stock.FDeleteFlag        = 0;
                stock.FMemo              = txtFMemo.Text.Trim();
                stock.FDate              = txtFDate.SelectedDate;
                stock.FDistributionPoint = ddlFDistributionPoint.SelectedValue;

                var parms = new Dictionary <string, object>();
                parms.Clear();

                parms.Add("@keyID", stock.KeyId);
                parms.Add("@companyId", CurrentUser.AccountComId);
                var amt =
                    Convert.ToDecimal(SqlService.ExecuteProcedureCommand("proc_PurchaseAmt", parms).Tables[0].Rows[0][0]);

                stock.FAmount = amt;

                StockInService.SaveChanges();

                if (txtKeyId.Text.Contains("TM"))
                {
                    //单据号问题
                    string newKeyId   = SequenceService.CreateSequence(Convert.ToDateTime(txtFDate.SelectedDate), "PY", CurrentUser.AccountComId);
                    var    orderParms = new Dictionary <string, object>();
                    orderParms.Clear();
                    orderParms.Add("@oldKeyId", txtKeyId.Text);
                    orderParms.Add("@newKeyId", newKeyId);
                    orderParms.Add("@Bill", "10");
                    orderParms.Add("@companyId", CurrentUser.AccountComId);
                    SqlService.ExecuteProcedureCommand("proc_num", orderParms);
                    txtKeyId.Text = newKeyId;

                    //新增日志
                    var billStatus = new LHBillStatus
                    {
                        KeyId       = newKeyId,
                        FCompanyId  = CurrentUser.AccountComId,
                        FActionName = "新增",
                        FDate       = DateTime.Now,
                        FDeptId     = CurrentUser.AccountOrgId,
                        FOperator   = CurrentUser.AccountName,
                        FMemo       = String.Format("单据号{0},{1}新增盘盈单据。", newKeyId, CurrentUser.AccountName)
                    };
                    GasHelper.AddBillStatus(billStatus);
                }

                return(true);
            }
            return(false);
        }
Пример #13
0
        /// <summary>
        ///     加载页面数据
        /// </summary>
        private void LoadData()
        {
            switch (Actions)
            {
            case WebAction.Add:
                txtKeyId.Text = SequenceService.CreateSequence("TM", CurrentUser.AccountComId);
                Region1.Title = "添加一般费用单";
                var temp = new LHFKOrder
                {
                    keyId = txtKeyId.Text,

                    FFlag = 1,

                    FDeleteFlag = 1,

                    //一般费用单
                    FType = Convert.ToInt32(GasEnumBill.GeneralExpense),

                    CreateBy = CurrentUser.AccountName,

                    FDate = txtFDate.SelectedDate,

                    FAmount = 0,

                    FCate = "内",

                    FCompanyId = CurrentUser.AccountComId
                };

                //临时写入单据
                FKOrderService.Add(temp);

                var summary = new JObject
                {
                    { "FCode", "合计" },
                    { "FAmt", 0 },
                };

                Grid1.SummaryData = summary;

                break;

            case WebAction.Edit:
                txtKeyId.Text = KeyId;
                Region1.Title = "编辑一般费用单";
                if (SkOrder != null)
                {
                    txtFCode.Text     = SkOrder.FCode;
                    tbxFCustomer.Text = SkOrder.FName;
                    txtFMemo.Text     = SkOrder.FMemo;

                    BindDataGrid();
                }
                break;
            }
        }
Пример #14
0
        /// <summary>
        ///     加载页面数据
        /// </summary>
        private void LoadData()
        {
            switch (Actions)
            {
            case WebAction.Add:
                txtKeyId.Text = SequenceService.CreateSequence("TM", CurrentUser.AccountComId);
                Region1.Title = "添加核销收单";

                var temp = new LHSKOrderChecked
                {
                    KeyId = txtKeyId.Text,

                    FFlag = 1,

                    FDeleteFlag = 1,

                    CreateBy = CurrentUser.AccountName,

                    FDate = txtFDate.SelectedDate,

                    FAmount = 0,

                    FCate = "客户",

                    FCompanyId = CurrentUser.AccountComId,
                };

                //临时写入单据
                CheckedOrderService.Add(temp);


                //    var summary = new JObject
                //{
                //    {"FCode", "合计"},
                //    {"FAmt", 0},
                //};

                //    Grid1.SummaryData = summary;

                break;

            case WebAction.Edit:
                Region1.Title = "编辑核销收单";
                txtKeyId.Text = KeyId;
                if (CheckedOrder != null)
                {
                    txtFCode.Text     = CheckedOrder.FCode;
                    tbxFCustomer.Text = CheckedOrder.FName;
                    txtFMemo.Text     = CheckedOrder.FMemo;

                    BindDataGrid();
                }
                break;
            }
        }
Пример #15
0
        /// <summary>
        ///     提交添加
        /// </summary>
        private bool SubmintAdd()
        {
            var dispatch = DispatchService.Where(p => p.KeyId == txtKeyId.Text.Trim() && //
                                                 p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault();

            if (dispatch != null)
            {
                //dispatch.KeyId = txtKeyId.Text.Trim();
                //dispatch.FCompanyId = CurrentUser.AccountComId;

                dispatch.CreateBy        = CurrentUser.AccountName;
                dispatch.FAccidentQty    = Convert.ToInt32(txtFAccidentQty.Text.Trim());
                dispatch.FDate           = txtFDate.SelectedDate;
                dispatch.FDispatcher     = ddlDispatcher.SelectedValue;
                dispatch.FHeavyTruckQty  = Convert.ToDecimal(txtFHeavyTruckQty.Text.Trim());
                dispatch.FIDepartureTime = Convert.ToInt32(txtFIDepartureTime.Text.Trim());
                dispatch.FIQty           = Convert.ToDecimal(txtFIQty.Text.Trim());
                dispatch.FIRange         = Convert.ToDecimal(txtFIRange.Text.Trim());
                dispatch.FLogistics      = ddlLogistics.SelectedValue;
                dispatch.FLogisticsName  = ddlLogistics.SelectedText;

                dispatch.FMemo           = txtFMemo.Text.Trim();
                dispatch.FODepartureTime = Convert.ToInt32(txtFODepartureTime.Text.Trim());
                dispatch.FOQty           = Convert.ToDecimal(txtFOQty.Text.Trim());
                dispatch.FORange         = Convert.ToDecimal(txtFORange.Text.Trim());
                dispatch.FOtherQty       = Convert.ToInt32(txtFOtherQty.Text.Trim());
                dispatch.FRepairQty      = Convert.ToInt32(txtFRepairQty.Text.Trim());
                dispatch.FTransport      = Convert.ToDecimal(txtFTransport.Text.Trim());
                dispatch.FTurnover       = Convert.ToDecimal(txtFTurnover.Text.Trim());
                dispatch.FWorkQty        = Convert.ToInt32(txtFWorkQty.Text.Trim());
                dispatch.FDeleteFlag     = 0;
                dispatch.FType           = 52;

                DispatchService.SaveChanges();

                if (txtKeyId.Text.Contains("TM"))
                {
                    //单据号问题
                    string newKeyId = SequenceService.CreateSequence(Convert.ToDateTime(txtFDate.SelectedDate),//
                                                                     "DL", CurrentUser.AccountComId);
                    var orderParms = new Dictionary <string, object>();
                    orderParms.Clear();
                    orderParms.Add("@oldKeyId", txtKeyId.Text);
                    orderParms.Add("@newKeyId", newKeyId);
                    orderParms.Add("@Bill", "52");//Convert.ToInt32(GasEnumBill.Dispatch)
                    orderParms.Add("@companyId", CurrentUser.AccountComId);

                    SqlService.ExecuteProcedureCommand("proc_num", orderParms);
                    txtKeyId.Text = newKeyId;

                    return(true);
                }
            }
            return(false);
        }
Пример #16
0
        public HttpResponseMessage TitlesUpdate(SequenceTitlesUpdateRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }
            ItemResponse <int> response = new ItemResponse <int>();

            response.Item = SequenceService.TitlesUpdate(model);
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Пример #17
0
        public HttpResponseMessage Update(SequenceUpdateRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }
            SequenceService.Update(model);
            SuccessResponse response = new SuccessResponse();

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Пример #18
0
        //refreshes the entire screen
        public void ArrangeSequences()
        {
            //arrange subroutes not in route
            SubrouteService subService = new SubrouteService();

            SubroutesNotinRoute = new ObservableCollection <Subroute>(subService.GetSubroutesNotInRoute(Route));

            //generate sequences here (sequence service + getlist sequences)
            SequenceService seqService = new SequenceService();

            Sequences = new ObservableCollection <Sequence>(seqService.GetSequences(Route));
        }
Пример #19
0
        protected void fileUpload1_FileSelected(object sender, EventArgs e)
        {
            if (fileUpload1.HasFile)
            {
                var fileSuffix = fileUpload1.ShortFileName.Substring(fileUpload1.ShortFileName.LastIndexOf('.'));

                var sequence = SequenceService.CreateSequence("LH", CurrentUser.AccountComId);

                var fileName = sequence + fileSuffix;

                var uploadpath = Config.GetUploadpath();

                //该目录设定死,最好不要修改
                var fileTemp = (string.Format(@"{0}/temp/{1}/", uploadpath, DateTime.Now.ToString("yyyy-MM-dd"))); //

                if (!DirFile.XFileExists(Server.MapPath(fileTemp)))
                {
                    DirFile.XCreateDir(Server.MapPath(fileTemp));
                }

                var address = fileTemp + fileName;

                fileUpload1.SaveAs(Server.MapPath(address));

                //导入
                var connStr = string.Empty;//数据连接字符串
                if (fileSuffix == ".xls")
                {
                    connStr = "Provider=Microsoft.Jet.OleDb.4.0;" + "data source=" + Server.MapPath(address) + ";Extended Properties='Excel 8.0; HDR=YES; IMEX=1'";
                }
                else if (fileSuffix == ".xlsx")
                {
                    connStr = "Provider=Microsoft.ACE.OleDb.12.0;" + "data source=" + Server.MapPath(address) + ";Extended Properties='Excel 12.0; HDR=YES; IMEX=1'";
                }

                var conn = new OleDbConnection(connStr);
                conn.Open();

                var          data   = new DataTable();
                const string cmdSql = "select * from [Sheet1$]";
                var          da     = new OleDbDataAdapter(cmdSql, conn);
                da.Fill(data);

                ViewState["dtData"] = data;
                Grid1.DataSource    = data;
                Grid1.DataBind();
                Grid1.Visible = true;

                fileUpload1.Reset();
            }
        }
Пример #20
0
        public async Task <int> insert(DbConnectionService dbcs)
        {
            string sql = "INSERT INTO Article VALUES(:Id, :UserId, :PostDate, :Text, :CreatedAt, :UpdatedAt)";

            SequenceService seq    = new SequenceService();
            var             Id     = seq.getNextVal(SequenceService.seqType.Article);
            var             now    = DateTime.Now;
            var             result = await dbcs.GetConnection().ExecuteAsync(sql, new
            {
                Id = Id
                ,
                UserId = this.User.Id
                ,
                PostDate = this.PostDate
                ,
                Text = this.Text
                ,
                CreatedAt = now
                ,
                UpdatedAt = now
            }, dbcs.GetTransaction());

            if (result == 1)
            {
                this.Id = Decimal.ToInt64(Id);

                List <Task <int> > task = new List <Task <int> >();
                foreach (var artC in this.Contents)
                {
                    artC.ArticleId = this.Id;
                    task.Add(artC.insert(dbcs));
                }
                int[] retC = await Task.WhenAll(task);

                foreach (var r in retC)
                {
                    if (r == 0)
                    {
                        throw new InvalidOperationException("Error:Insert ArticleContents");
                    }
                    result += r;
                }

                return(result);
            }
            else
            {
                throw new InvalidOperationException("Error:Insert Article");
            }
        }
Пример #21
0
        /// <summary>
        ///     提交添加
        /// </summary>
        private bool SubmintAdd()
        {
            var stock = DispatchCommissionService.Where(p => p.KeyId == txtKeyId.Text.Trim() && p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault();

            if (stock != null)
            {
                AddListGrid();

                ModifiedGrid();
                /////////////////////////////////////////////////////////////////////////////
                stock.FDate = txtFDate.SelectedDate;
                stock.FMemo = txtFMemo.Text.Trim();

                DispatchCommissionService.SaveChanges();

                if (txtKeyId.Text.Contains("TM"))
                {
                    //单据号问题
                    string newKeyId   = SequenceService.CreateSequence(Convert.ToDateTime(txtFDate.SelectedDate), "TC", CurrentUser.AccountComId);
                    var    orderParms = new Dictionary <string, object>();
                    orderParms.Clear();
                    orderParms.Add("@oldKeyId", txtKeyId.Text);
                    orderParms.Add("@newKeyId", newKeyId);
                    orderParms.Add("@Bill", "14");
                    orderParms.Add("@companyId", CurrentUser.AccountComId);

                    SqlService.ExecuteProcedureCommand("proc_num", orderParms);
                    txtKeyId.Text = newKeyId;

                    //新增日志
                    var billStatus = new LHBillStatus
                    {
                        KeyId       = newKeyId,
                        FCompanyId  = CurrentUser.AccountComId,
                        FActionName = "新增",
                        FDate       = DateTime.Now,
                        FDeptId     = CurrentUser.AccountOrgId,
                        FOperator   = CurrentUser.AccountName,
                        FMemo       = String.Format("单据号{0},{1}新增送货提成单据。", newKeyId, CurrentUser.AccountName)
                    };

                    GasHelper.AddBillStatus(billStatus);
                }

                return(true);
            }

            return(false);
        }
Пример #22
0
        public void TaskComplete(string TaskId)
        {
            lock (_taskServiceLock)
            {
                Log.Info("Задача " + TaskId + ", получено сообщение о завершении");

                const int ATTEMPTS_MAX = 3;
                bool      success      = false;
                var       rnd          = new Random();

                for (int i = 0; i < ATTEMPTS_MAX && !success; i++)
                {
                    try
                    {
                        Task task = Task.Load(TaskId);
                        Log.Stats("T_clust_fin", task.SequenceId, task.TaskId, DateTime.Now);

                        task.Complete();
                        success = true;
                        task.Save();

                        Log.Stats("T_task_fin", task.SequenceId, task.TaskId, DateTime.Now);

                        if (task.SequenceId > 0)
                        {
                            var sequenceService = new SequenceService();
                            sequenceService.StepFinishedCallback(task.SequenceId);
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Error(String.Format(
                                      "Задача {2}, возникло исключение при завершении\n{0}\n{1}", e.Message, e.StackTrace, TaskId
                                      ));
                    }


                    Thread.Sleep(rnd.Next(2 * 1000), 10 * 1000);
                }

                if (!success)
                {
                    TaskFail(TaskId);
                }
            }
        }
Пример #23
0
        /// <summary>
        ///     加载页面数据
        /// </summary>
        private void LoadData()
        {
            switch (Actions)
            {
            case WebAction.Add:
                hiddevalue.Text = SequenceService.CreateSequence(DateTime.Now, "CC", CurrentUser.AccountComId);
                BindData();
                break;

            case WebAction.Edit:

                if (Contract != null)
                {
                    Customer = CustomerService.FirstOrDefault(p => p.FCode == Contract.FCustomer && p.FCompanyId == CurrentUser.AccountComId);
                    if (CurrentUser != null)
                    {
                        tbxFCustomer.Text = Customer.FName;
                    }
                    hiddevalue.Text              = Contract.FOrderCode;
                    txtFContractCode.Text        = Contract.FContractCode;
                    dpFContractDate.SelectedDate = Contract.FContractDate;
                    txtFContractName.Text        = Contract.FContractName;
                    ddlFCtroler.SelectedValue    = Contract.FCtroler;
                    //txtFContractName.Text = Contract.FContractName;
                    if (!string.IsNullOrEmpty(ddlFAccType.SelectedValue))
                    {
                        ddlFAccType.SelectedValue = Contract.FAccType;
                    }
                    if (!string.IsNullOrEmpty(ddlFBillType.SelectedValue))
                    {
                        ddlFBillType.SelectedValue = Contract.FBillType;
                    }
                    dpFBeginDate.SelectedDate = Contract.FBeginDate;
                    dpFEndDate.SelectedDate   = Contract.FEndDate;
                    this.txtFCustomer.Text    = Contract.FCustomer;

                    txtFContext.Text  = Contract.FContext;
                    txtFConacter.Text = Contract.FConacter;
                    txtFTel.Text      = Contract.FTel;
                    BindData();
                }
                break;
            }
        }
Пример #24
0
        public void TaskFail(string TaskId)
        {
            lock (_taskServiceLock)
            {
                try
                {
                    Task task = Task.Load(TaskId);
                    task.Fail();
                    task.Save();

                    var sequenceService = new SequenceService();
                    sequenceService.StepFinishedCallback(task.SequenceId);
                }
                catch (Exception e)
                {
                    Log.Error(String.Format(
                                  "Задача {2}, возникло исключение при завершении со статусом Fail\n{0}\n{1}", e.Message, e.StackTrace, TaskId
                                  ));
                }
            }
        }
Пример #25
0
        public void TaskAbort(string TaskId)
        {
            lock (_taskServiceLock)
            {
                try
                {
                    Task task = Task.Load(TaskId);
                    task.Abort();
                    task.Save();

                    var sequenceService = new SequenceService();
                    sequenceService.StepFinishedCallback(task.SequenceId);
                }
                catch (Exception e)
                {
                    Log.Error(String.Format(
                                  "Задача {2}, возникло исключение при попытке принудительного завершения\n{0}\n{1}", e.Message, e.StackTrace, TaskId
                                  ));
                }
            }
        }
Пример #26
0
        public void TaskAbort(string TaskId)
        {
            lock (_taskServiceLock)
            {
                try
                {
                    Task task = Task.Load(TaskId);
                    task.Abort();
                    task.Save();

                    var sequenceService = new SequenceService();
                    sequenceService.StepFinishedCallback(task.SequenceId);
                }
                catch (Exception e)
                {
                    Log.Error(String.Format(
                        "Задача {2}, возникло исключение при попытке принудительного завершения\n{0}\n{1}", e.Message, e.StackTrace, TaskId
                    ));
                }
            }
        }
Пример #27
0
        public void Run_sequences_performance()
        {
            var repository = new EFAppConfigRepository("VirtoCommerce");
            var sequence   = new SequenceService(repository);


            for (var i = 1; i < SequenceService.SequenceReservationRange; i++)
            {
                var result = sequence.GetNext("test");
                Debug.WriteLine(result);

                //This would fail if any duplicate generated
                Assert.IsFalse(GlobalNumbers.ContainsKey(result));
                GlobalNumbers.Add(result, result);

                const string sql = "INSERT UniqueSequence VALUES(@p0);";
                //This would fail if any duplicate generated beause we use primary key
                var sqlResult = repository.Database.ExecuteSqlCommand(sql, result);
                Assert.AreEqual(1, sqlResult);
            }
        }
        public void Run_sequences_performance()
        {
            var repository = new EFAppConfigRepository("VirtoCommerce");
            var sequence = new SequenceService(repository);


            for (var i = 1; i < SequenceService.SequenceReservationRange; i++)
            {
                var result = sequence.GetNext("test");
                Debug.WriteLine(result);

                //This would fail if any duplicate generated
                Assert.IsFalse(GlobalNumbers.ContainsKey(result));
                GlobalNumbers.Add(result, result);

                const string sql = "INSERT UniqueSequence VALUES(@p0);";
                //This would fail if any duplicate generated beause we use primary key
                var sqlResult = repository.Database.ExecuteSqlCommand(sql, result);
                Assert.AreEqual(1,sqlResult);
            }
        }
Пример #29
0
        public SequenceServiceTests()
        {
            _log = new LogToMemory();

            fromAddress = new BitcoinPubKeyAddress(from);
            fromKey     = Key.Parse(fromPrivateKey);
            toAddress   = new BitcoinPubKeyAddress(to);
            tx          = txBuilder
                          .AddCoins(prevTx.Outputs.AsCoins().Where(c => c.ScriptPubKey.GetDestinationAddress(network).ToString() == from).ToArray())
                          .Send(toAddress, Money.Coins(1))
                          .SetChange(fromAddress)
                          .SubtractFees()
                          .SendFees(txBuilder.EstimateFees(new FeeRate(Money.Satoshis(1024))))
                          .BuildTransaction(false);
            spentCoins = txBuilder.FindSpentCoins(tx);
            service    = new SequenceService(_log, "sequence-testnet");

            serviceProvider = new Mock <IServiceProvider>();
            serviceProvider.Setup(provider => provider.GetService(typeof(ISequenceService)))
            .Returns(service);
        }
Пример #30
0
        private void grdBusinessCard_Sorted(object sender, EventArgs e)
        {
            // 设置鼠标繁忙状态,并保留原先的状态
            Cursor holdCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            if (this.permissionEdit)
            {
                SequenceService sequenceService = new SequenceService();
                string[]        sequence        = sequenceService.GetBatchSequence(UserInfo, BaseBusinessCardTable.TableName, this.DTBusinessCard.DefaultView.Count);
                int             i = 0;
                foreach (DataRowView DataRowView in this.DTBusinessCard.DefaultView)
                {
                    DataRowView.Row[BaseBusinessCardTable.FieldSortCode] = sequence[i];
                    i++;
                }
                // 控制导航按钮
                this.SetSortButton(false);
            }
            // 设置鼠标默认状态,原来的光标状态
            this.Cursor = holdCursor;
        }
        public void GetSequences__NumberMultipleThreeAndMultipleFive__SuccessfulResult()
        {
            // Arrange
            int inputNumber     = 15;
            var sequenceService = new SequenceService();

            // Act
            SequencesResponse sequencesObject = (SequencesResponse)sequenceService.ProcessNumber(inputNumber);

            // Assert
            Assert.Equal(new List <int> {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
            }, sequencesObject.AllNumbersSequence.ToList());
            Assert.Equal(new List <int> {
                1, 3, 5, 7, 9, 11, 13, 15
            }, sequencesObject.OddNumbersSequence.ToList());
            Assert.Equal(new List <int> {
                2, 4, 6, 8, 10, 12, 14
            }, sequencesObject.EvenNumbersSequence.ToList());
            Assert.Null(sequencesObject.AllNumbersSecondSequence);
            Assert.Equal('Z', sequencesObject.CharacterOutput);
        }
Пример #32
0
        public ActionResult Edit(NodeVM vm)
        {
            if (!ModelState.IsValid || !vm.IsValid(ModelState))
            {
                return(View(vm));
            }

            var node = NodeVM.ToModel(vm);

            node.UpdateAt = DateTime.Now;
            if (node.NodeId == 0)
            {
                node.NodeId   = SequenceService.Next(Constants.SEQUENCE_SETTINGS_NODE, 1);
                node.CreateAt = node.UpdateAt;
            }

            if (vm.Deleted)
            {
                node.DeleteAt = node.UpdateAt;
                if (!NodeService.DeleteNode(node))
                {
                    ModelState.AddModelError(string.Empty, "Failed to delete, other users may have edited the data during your processing");
                    return(View(vm));
                }
                Info = "Delete successfully";
                return(RedirectToAction("Group", "Node"));
            }
            else
            {
                if (!NodeService.SaveNode(node))
                {
                    ModelState.AddModelError(string.Empty, "Failed to save, other users may have edited the data during your processing");
                    return(View(vm));
                }
                Info = "Saved successfully";
                return(RedirectToAction("Edit", new { id = node.NodeId }));
            }
        }
Пример #33
0
        public void TaskFail(string TaskId)
        {
            lock (_taskServiceLock)
            {
                try
                {
                    Task task = Task.Load(TaskId);
                    task.Fail();
                    task.Save();

                    var sequenceService = new SequenceService();
                    sequenceService.StepFinishedCallback(task.SequenceId);
                }
                catch (Exception e)
                {
                    Log.Error(String.Format(
                        "Задача {2}, возникло исключение при завершении со статусом Fail\n{0}\n{1}", e.Message, e.StackTrace, TaskId
                    ));
                }
            }
        }
Пример #34
0
        public void TaskComplete(string TaskId)
        {
            lock (_taskServiceLock)
            {
                Log.Info("Задача " + TaskId + ", получено сообщение о завершении");

                const int ATTEMPTS_MAX = 3;
                bool success = false;
                var rnd = new Random();

                for (int i = 0; i < ATTEMPTS_MAX && !success; i++)
                {
                    try
                    {
                        Task task = Task.Load(TaskId);
                        Log.Stats("T_clust_fin", task.SequenceId, task.TaskId, DateTime.Now);

                        task.Complete();
                        success = true;
                        task.Save();

                        Log.Stats("T_task_fin", task.SequenceId, task.TaskId, DateTime.Now);

                        if (task.SequenceId > 0)
                        {
                            var sequenceService = new SequenceService();
                            sequenceService.StepFinishedCallback(task.SequenceId);
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Error(String.Format(
                            "Задача {2}, возникло исключение при завершении\n{0}\n{1}", e.Message, e.StackTrace, TaskId
                        ));
                    }

                    Thread.Sleep(rnd.Next(2*1000), 10*1000);
                }

                if (!success)
                    TaskFail(TaskId);
            }
        }