Example #1
0
        /// <summary>
        /// 删除焦点对象
        /// </summary>
        ///
        public void DeleteObject()
        {
            //获取焦点对象
            Line_Info obj = FocusedObject;

            if (obj == null)
            {
                return;
            }

            //请求确认
            if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes)
            {
                return;
            }

            //执行删除操作
            try
            {
                Services.BaseService.Delete <Line_Info>(obj);
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return;
            }
            this.bandedGridView2.BeginUpdate();
            //记住当前焦点行索引
            int iOldHandle = this.bandedGridView2.FocusedRowHandle;

            //从链表中删除
            ObjectList.Remove(obj);
            //刷新表格
            gridControl.RefreshDataSource();
            //设置新的焦点行索引
            GridHelper.FocuseRowAfterDelete(this.bandedGridView2, iOldHandle);
            this.bandedGridView2.EndUpdate();
        }
Example #2
0
 /// <summary>
 /// 发送数据
 /// </summary>
 /// <param name="bytes">数据字节</param>
 public void Send(byte[] bytes)
 {
     try
     {
         _socket.BeginSend(bytes, 0, bytes.Length, SocketFlags.None, asyncResult =>
         {
             try
             {
                 int length = _socket.EndSend(asyncResult);
                 HandleSendMsg?.Invoke(_server, this, bytes);
             }
             catch (Exception ex)
             {
                 HandleException?.Invoke(ex);
             }
         }, null);
     }
     catch (Exception ex)
     {
         HandleException?.Invoke(ex);
     }
 }
Example #3
0
        private void StartListen()
        {
            try
            {
                _socket.BeginAccept(asyncResult =>
                {
                    try
                    {
                        Socket newSocket = _socket.EndAccept(asyncResult);

                        //马上进行下一轮监听,增加吞吐量
                        if (_isListen)
                        {
                            StartListen();
                        }

                        TcpSocketConnection newConnection = new TcpSocketConnection(newSocket, this)
                        {
                            HandleRecMsg      = HandleRecMsg == null ? null : new Action <TcpSocketServer, TcpSocketConnection, byte[]>(HandleRecMsg),
                            HandleClientClose = HandleClientClose == null ? null : new Action <TcpSocketServer, TcpSocketConnection>(HandleClientClose),
                            HandleSendMsg     = HandleSendMsg == null ? null : new Action <TcpSocketServer, TcpSocketConnection, byte[]>(HandleSendMsg),
                            HandleException   = HandleException == null ? null : new Action <Exception>(HandleException)
                        };

                        AddConnection(newConnection);
                        newConnection.StartRecMsg();
                        HandleNewClientConnected?.BeginInvoke(this, newConnection, null, null);
                    }
                    catch (Exception ex)
                    {
                        HandleException?.BeginInvoke(ex, null, null);
                    }
                }, null);
            }
            catch (Exception ex)
            {
                HandleException?.BeginInvoke(ex, null, null);
            }
        }
        /// <summary>
        /// 开始接受客户端消息
        /// </summary>
        private void StartRecMsg()
        {
            try
            {
                byte[] container = new byte[RecLength];
                _socket.BeginReceive(container, 0, container.Length, SocketFlags.None, asyncResult =>
                {
                    try
                    {
                        int length = _socket.EndReceive(asyncResult);

                        //马上进行下一轮接受,增加吞吐量
                        if (length > 0 && _isRec && IsSocketConnected())
                            StartRecMsg();

                        if (length > 0)
                        {
                            byte[] recBytes = new byte[length];
                            Array.Copy(container, 0, recBytes, 0, length);

                            //处理消息
                            HandleRecMsg?.Invoke(this, recBytes);
                        }
                        else
                            Close();
                    }
                    catch (Exception ex)
                    {
                        HandleException?.BeginInvoke(ex, null, null);
                        Close();
                    }
                }, null);
            }
            catch (Exception ex)
            {
                HandleException?.BeginInvoke(ex, null, null);
                Close();
            }
        }
Example #5
0
        public IQueryable <SectionModel> GetSections(int networkId, BridgeCareContext db)
        {
            IQueryable <SectionModel> rawQueryForData = null;

            var select = String.Format("SELECT sectionid, facility as referenceKey, section as referenceId, {0} as networkId FROM Section_{0}", networkId);

            try
            {
                rawQueryForData = db.Database.SqlQuery <SectionModel>(select).AsQueryable();
            }
            catch (SqlException ex)
            {
                log.Error(ex.Message);
                HandleException.SqlError(ex, "Section_");
            }
            catch (OutOfMemoryException ex)
            {
                log.Error(ex.Message);
                HandleException.OutOfMemoryError(ex);
            }
            return(rawQueryForData);
        }
        public async void LoadDataFromServer()
        {
            try
            {
                await LoadServerDataAsync();

                //Check preference login
                string IDLogin = Preferences.Get("IDLogin", string.Empty);
                if (string.IsNullOrEmpty(IDLogin))
                {
                    App.Current.MainPage = new NavigationPage(LoginView.GetInstance());
                    return;
                }

                string IDUser = Preferences.Get("UsernameLogin", string.Empty);
                User   user   = DataProvider.GetInstance().GetUserByIDUser(IDUser);
                if (user == null || user.ExternalId != IDLogin)
                {
                    OneSignal.Current.SetExternalUserId("");
                    //OneSignal.Current.SendTag("IsLogined", "0");
                    Preferences.Set("IDLogin", "");
                    App.Current.MainPage = new NavigationPage(LoginView.GetInstance());
                    return;
                }

                string username = Preferences.Get("UsernameLogin", string.Empty);
                string password = Preferences.Get("PasswordLogin", string.Empty);
                var    middle   = new MiddleView(username, password);
                middle.ChangeAlreadyLogin();

                await App.Current.MainPage.Navigation.PushAsync(middle);
            }
            catch (Exception e)
            {
                Busy = false;
                HandleException.Onboarding();
                return;
            }
        }
Example #7
0
 private void aisinoDataGrid1_DataGridRowClickEvent(object sender, DataGridRowEventArgs e)
 {
     try
     {
         this.SelectedBH = e.get_CurrentRow().Cells["BH"].Value.ToString().Trim();
         this.aisinoDataGrid2.set_DataSource(this.hzBLL.QueryXSDJMX(this.SelectedBH, this.hzBLL.Pagesize, this.hzBLL.CurrentPage));
         this.bill = this.billBL.Find(this.SelectedBH);
         int count = this.aisinoDataGrid2.get_Rows().Count;
         for (int i = 0; i < count; i++)
         {
             string str  = this.aisinoDataGrid2.get_Rows()[i].Cells["SLV"].Value.ToString();
             string str2 = this.aisinoDataGrid2.get_Rows()[i].Cells["XH"].Value.ToString();
             if (((str != null) && (str != "")) && (str != "中外合作油气田"))
             {
                 string str3 = this.billBL.ShowSLV(this.bill, str2, str);
                 if (str3 != "")
                 {
                     this.aisinoDataGrid2.get_Rows()[i].Cells["SLV"].Value = str3;
                 }
             }
         }
         string str4 = this.billBL.CollectDiscount(this.bill);
         if (str4 == "0")
         {
             this.DisplayZKHZH();
         }
         else
         {
             this.aisinoDataGrid3.set_DataSource(this.hzBLL.QueryXSDJMX("NoExist", this.hzBLL.Pagesize, 1));
             HandleException.Log.Error("该单据不可以进行折扣汇总:" + str4);
             MessageBoxHelper.Show(str4);
         }
     }
     catch (Exception exception)
     {
         HandleException.HandleError(exception);
     }
 }
Example #8
0
        public DeficientResult GetData(SimulationModel data, int[] totalYears)
        {
            // Deficient and DeficientResults are models. Deficient gets data
            // from the database. DeficientResult gets the processed data
            IQueryable <DeficientReportModel> deficients = null;
            DeficientResult result = null;

            var select =
                "SELECT TargetID, Years, coalesce(TARGETMET, 0) as TargetMet, IsDeficient " +
                " FROM Target_" + data.networkId
                + "_" + data.simulationId;

            try
            {
                var rawDeficientList = db.Database.SqlQuery <DeficientReportModel>(select).AsQueryable();

                deficients = rawDeficientList.Where(_ => _.IsDeficient == true);

                var targetAndYear = this.deficients.GetData(deficients);
                result = GetDeficientInformation(data, targetAndYear, totalYears);
            }
            catch (SqlException ex)
            {
                log.Error(ex.Message);
                HandleException.SqlError(ex, "Target");
            }
            catch (OutOfMemoryException ex)
            {
                log.Error(ex.Message);
                HandleException.OutOfMemoryError(ex);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                HandleException.GeneralError(ex);
            }
            return(result);
        }
Example #9
0
        private void StartListen()
        {
            try
            {
                _socket.BeginAccept(asyncResult =>
                {
                    try
                    {
                        Socket newSocket = _socket.EndAccept(asyncResult);
                        if (_isListen)
                        {
                            StartListen();
                        }

                        SocketConnection newClient = new SocketConnection(newSocket, this)
                        {
                            HandleRecMsg      = HandleRecMsg == null ? null : new Action <byte[], SocketConnection, SocketServer>(HandleRecMsg),
                            HandleClientClose = HandleClientClose == null ? null : new Action <SocketConnection, SocketServer>(HandleClientClose),
                            HandleSendMsg     = HandleSendMsg == null ? null : new Action <byte[], SocketConnection, SocketServer>(HandleSendMsg),
                            HandleException   = HandleException == null ? null : new Action <Exception>(HandleException)
                        };

                        newClient.StartRecMsg();
                        ClientList.AddLast(newClient);

                        HandleNewClientConnected?.Invoke(this, newClient);
                    }
                    catch (Exception ex)
                    {
                        HandleException?.Invoke(ex);
                    }
                }, null);
            }
            catch (Exception ex)
            {
                HandleException?.Invoke(ex);
            }
        }
Example #10
0
        /// <summary>
        /// 发送数据
        /// </summary>
        /// <param name="bytes">数据</param>
        /// <param name="iPEndPoint">目标地址</param>
        public void Send(byte[] bytes, IPEndPoint iPEndPoint)
        {
            try
            {
                _udpClient.BeginSend(bytes, bytes.Length, iPEndPoint, asyncCallback =>
                {
                    try
                    {
                        int length = _udpClient.EndSend(asyncCallback);

                        HandleSendMsg?.BeginInvoke(this, iPEndPoint, bytes, null, null);
                    }
                    catch (Exception ex)
                    {
                        HandleException?.BeginInvoke(ex, null, null);
                    }
                }, null);
            }
            catch (Exception ex)
            {
                HandleException?.BeginInvoke(ex, null, null);
            }
        }
Example #11
0
        public List <YearlyDataModel> GetYearsData(SimulationModel data)
        {
            var yearsForBudget = new List <YearlyDataModel>();

            try
            {
                yearsForBudget = db.YearlyInvestments.AsNoTracking().Where(_ => _.SIMULATIONID == data.simulationId)
                                 .OrderBy(year => year.YEAR_)
                                 .Select(p => new YearlyDataModel
                {
                    Year       = p.YEAR_,
                    Amount     = p.AMOUNT,
                    BudgetName = p.BUDGETNAME
                }).ToList();
            }
            catch (SqlException ex)
            {
                var log = log4net.LogManager.GetLogger(typeof(DetailedReportDAL));
                log.Error(ex.Message);
                HandleException.SqlError(ex, "Years");
            }
            return(yearsForBudget);
        }
Example #12
0
 private void aisinoDataGrid1_GoToPageEvent(object sender, GoToPageEventArgs e)
 {
     try
     {
         this.djcfBLL.Pagesize = e.get_PageSize();
         string str = e.get_PageNO().ToString();
         PropertyUtil.SetValue("WBJK_DJCF_DATAGRID1", str);
         if (this.JYrule == "s")
         {
             this.aisinoDataGrid1.remove_DataGridRowSelectionChanged(new EventHandler <DataGridRowEventArgs>(this.aisinoDataGrid1_DataGridRowSelectionChanged));
             this.CheckAdd(e.get_PageSize(), e.get_PageNO());
             this.aisinoDataGrid1.add_DataGridRowSelectionChanged(new EventHandler <DataGridRowEventArgs>(this.aisinoDataGrid1_DataGridRowSelectionChanged));
         }
         else
         {
             this.aisinoDataGrid1.set_DataSource(this.djcfBLL.QueryXSDJ(this.KeyWords, this.DJmonth, this.DJtype, this.JYrule, e.get_PageSize(), e.get_PageNO()));
         }
     }
     catch (Exception exception)
     {
         HandleException.HandleError(exception);
     }
 }
Example #13
0
 private void btnQuery_Click(object sender, EventArgs e)
 {
     try
     {
         this.DJmonth = this.comboBoxYF.SelectedItem.ToString();
         this.DJtype  = this.comboBoxDJZL.SelectedValue.ToString();
         this.GFname  = this.textBoxMC.Text.Trim();
         this.GFsh    = this.textBoxSH.Text.Trim();
         this.aisinoDataGrid1.set_DataSource(this.djhbBLL.QueryXSDJ(this.DJmonth, this.DJtype, this.GFname, this.GFsh));
         if (this.aisinoDataGrid1.get_Rows().Count > 0)
         {
             this.aisinoDataGrid1.get_Rows()[0].Selected = true;
         }
         if (this.aisinoDataGrid1.get_DataSource().get_Data().Rows.Count == 0)
         {
             MessageManager.ShowMsgBox("INP-272203");
         }
     }
     catch (Exception exception)
     {
         HandleException.HandleError(exception);
     }
 }
Example #14
0
 /// <summary>
 /// 开始服务,监听客户端
 /// </summary>
 public void StartServer()
 {
     try
     {
         //实例化套接字(ip4寻址协议,流式传输,TCP协议)
         _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         //创建ip对象
         IPAddress address = IPAddress.Parse(_ip);
         //创建网络节点对象包含ip和port
         IPEndPoint endpoint = new IPEndPoint(address, _port);
         //将 监听套接字绑定到 对应的IP和端口
         _socket.Bind(endpoint);
         //设置监听队列长度为Int32最大值(同时能够处理连接请求数量)
         _socket.Listen(int.MaxValue);
         //开始监听客户端
         StartListen();
         HandleServerStarted?.BeginInvoke(this, null, null);
     }
     catch (Exception ex)
     {
         HandleException?.BeginInvoke(ex, null, null);
     }
 }
Example #15
0
 protected virtual ActionResult Create()
 {
     try
     {
         CustomPrincipal cp = (System.Web.HttpContext.Current.User as CustomPrincipal);
         if (cp != null)
         {
             int compId = cp.CompanyID;
             int userID = cp.CurrentUserId;
             ViewBag.SequenceNo   = ProductRepo.getProduct(compId).Select(o => o.SequenceNo).Max() + 1;
             ViewBag.CategoryList = CatRepo.getCategory(compId);
             return(View());
         }
         else
         {
             return(RedirectToAction("Index", "Login"));
         }
     }
     catch (Exception ex)
     {
         return(HandleException.CustomException("Create", "Product"));
     }
 }
Example #16
0
        /// <summary>
        /// 关闭当前连接
        /// </summary>
        public void Close()
        {
            if (_isClosed)
            {
                return;
            }
            try
            {
                _isClosed = true;
                _server.RemoveConnection(this);

                _isRec = false;
                _socket.BeginDisconnect(false, (asyncCallback) =>
                {
                    try
                    {
                        _socket.EndDisconnect(asyncCallback);
                    }
                    catch (Exception ex)
                    {
                        HandleException?.BeginInvoke(ex, null, null);
                    }
                    finally
                    {
                        _socket.Dispose();
                    }
                }, null);
            }
            catch (Exception ex)
            {
                HandleException?.BeginInvoke(ex, null, null);
            }
            finally
            {
                HandleClientClose?.BeginInvoke(_server, this, null, null);
            }
        }
Example #17
0
 private void comboBoxYF_TextChanged(object sender, EventArgs e)
 {
     try
     {
         int    num  = 0;
         bool   flag = false;
         string item = this.comboBoxYF.Text.Trim();
         if (this.UseYear && (item != "0"))
         {
             string[] strArray = item.Split(new char[] { '-' });
             if (strArray.Length == 2)
             {
                 item = strArray[1].Trim();
             }
         }
         if (this.listrMonths.Contains(item))
         {
             flag = true;
         }
         if (!flag)
         {
             this.btnOK.Enabled = false;
         }
         else if ((num < 0) || (num > 12))
         {
             this.btnOK.Enabled = false;
         }
         else
         {
             this.btnOK.Enabled = true;
         }
     }
     catch (Exception exception)
     {
         HandleException.HandleError(exception);
     }
 }
Example #18
0
        protected virtual void OnDrawRaffleVictor(PaymentClass paymentClass)
        {
            try
            {
                CanExecuteRaffle = false;
                WinningTicket    = null;

                CancellationTokenSource cts = new CancellationTokenSource();

                //todo: find a better way to handle this asynchronously
                Task.Run(() =>
                {
                    BeginUIWait(paymentClass, cts.Token);
                });


                Task.Run(async() =>
                {
                    var ticket = RaffleService.GetRandomTicket(paymentClass);

                    await Task.Delay(TimeSpan.FromSeconds(3));

                    return(ticket);
                })
                .ContinueWith((t) =>
                {
                    cts.Cancel();

                    WinningTicket    = t.Result;
                    CanExecuteRaffle = true;
                });
            }
            catch (Exception ex)
            {
                HandleException?.Invoke(this, ex);
            }
        }
 /// <summary>
 /// 关闭与服务器的连接
 /// </summary>
 public void Close()
 {
     try
     {
         _isRec = false;
         _socket.BeginDisconnect(false, asyncCallback =>
         {
             try
             {
                 _socket.EndDisconnect(asyncCallback);
             }
             catch (Exception ex)
             {
                 HandleException?.BeginInvoke(ex, null, null);
             }
             finally
             {
                 _socket.Dispose();
             }
         }, null);
     }
     catch (Exception ex)
     {
         HandleException?.BeginInvoke(ex, null, null);
     }
     finally
     {
         try
         {
             HandleClientClose?.Invoke(this);
         }
         catch (Exception ex)
         {
             HandleException?.Invoke(ex);
         }
     }
 }
Example #20
0
 private void btnQuery_Click(object sender, EventArgs e)
 {
     try
     {
         string        dJMonth = this.comboBoxYF.SelectedItem.ToString();
         string        dJType  = this.comboBoxDJZL.SelectedValue.ToString();
         string        keyWord = this.GetKeyWord();
         int           key     = this.GetKey();
         AisinoDataSet set     = this.hzBLL.QueryXSDJ(dJMonth, dJType, keyWord, this.hzBLL.Pagesize, this.hzBLL.CurrentPage, key);
         this.aisinoDataGrid1.set_DataSource(set);
         this.SelectedBH = "NoExist";
         this.aisinoDataGrid2.set_DataSource(this.hzBLL.QueryXSDJMX("NoExist", this.hzBLL.Pagesize, 1));
         this.aisinoDataGrid3.set_DataSource(this.hzBLL.QueryXSDJMX("NoExist", this.hzBLL.Pagesize, 1));
         int count = this.aisinoDataGrid2.get_Rows().Count;
         for (int i = 0; i < count; i++)
         {
             string str4 = this.aisinoDataGrid2.get_Rows()[i].Cells["SLV"].Value.ToString();
             string str5 = this.aisinoDataGrid2.get_Rows()[i].Cells["XH"].Value.ToString();
             if (((str4 != null) && (str4 != "")) && (str4 != "中外合作油气田"))
             {
                 string str6 = this.billBL.ShowSLV(this.bill, str5, str4);
                 if (str6 != "")
                 {
                     this.aisinoDataGrid2.get_Rows()[i].Cells["SLV"].Value = str6;
                 }
             }
         }
         if (set.get_Data().Rows.Count == 0)
         {
             MessageManager.ShowMsgBox("INP-272203");
         }
     }
     catch (Exception exception)
     {
         HandleException.HandleError(exception);
     }
 }
Example #21
0
        protected bool SaveRecord()
        {
            //创建/修改 对象
            try
            {
                if (IsCreate)
                {
                    Services.BaseService.Create <Substation_Info>(_obj);
                }
                else
                {
                    Services.BaseService.Update("UpdateSubstation_InfoAreaName", _obj);
                }
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return(false);
            }

            //操作已成功
            return(true);
        }
Example #22
0
        private void barButtonItem6_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //删除地区
            //获取焦点对象
            //修改地区
            object obj = this.gridView.GetRow(this.gridView.FocusedRowHandle);

            if (obj == null)
            {
                return;
            }

            PSP_35KVPingHeng objCopy = (PSP_35KVPingHeng)obj;

            objCopy.Title = objCopy.DiQu;

            //请求确认
            if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes)
            {
                return;
            }

            //执行删除操作
            try
            {
                Services.BaseService.Update("UpdatePSP_35KVPingHengByTypeAndTitleByDelete", obj);
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return;
            }

            InitData();
        }
        protected bool SaveRecord()
        {
            //创建/修改 对象
            try
            {
                if (IsCreate)
                {
                    UCDeviceBase.DataService.Create <LayoutList>(_obj);
                }
                else
                {
                    UCDeviceBase.DataService.Update <LayoutList>(_obj);
                }
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return(false);
            }

            //操作已成功
            return(true);
        }
Example #24
0
        /// <summary>
        /// 刷新表格中的数据
        /// </summary>
        /// <returns>ture:成功  false:失败</returns>
        public bool RefreshData()
        {
            try
            {
                IList <BaseColor> list = Services.BaseService.GetStrongList <BaseColor>();

                foreach (BaseColor bb in list)
                {
                    Color cl = ColorTranslator.FromOle(bb.Color);
                    bb.Color1 = cl;
                }


                this.gridControl.DataSource = list;
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return(false);
            }

            return(true);
        }
Example #25
0
 protected virtual ActionResult Edit(int id)
 {
     try
     {
         if (id > 0)
         {
             CustomPrincipal cp = (System.Web.HttpContext.Current.User as CustomPrincipal);
             if (cp != null)
             {
                 int compId = cp.CompanyID;
                 ViewBag.CategoryList = CatRepo.getCategory(compId);
                 Product oProduct = ProductRepo.getProduct(id, compId).FirstOrDefault();
                 if (oProduct != null)
                 {
                     return(View(oProduct));
                 }
                 else
                 {
                     return(HandleException.CustomException("Edit", "Product"));
                 }
             }
             else
             {
                 return(RedirectToAction("Index", "Login"));
             }
         }
         else
         {
             return(HandleException.CustomException("Edit", "Product"));
         }
     }
     catch (Exception ex)
     {
         return(HandleException.CustomException("Edit", "Product"));
     }
 }
Example #26
0
        /// <summary>
        /// 开始Wcf服务
        /// </summary>
        public void StartHost()
        {
            Task task = new Task(() =>
            {
                try
                {
                    if (HandleHostOpened != null)
                    {
                        _serviceHost.Opened += new EventHandler(HandleHostOpened);
                    }

                    if (_serviceHost.State != CommunicationState.Opened)
                    {
                        _serviceHost.Open();
                    }
                }
                catch (Exception ex)
                {
                    HandleException?.Invoke(ex);
                }
            });

            task.Start();
        }
Example #27
0
        protected virtual ActionResult Delete(int id)
        {
            try
            {
                CustomPrincipal cp = (System.Web.HttpContext.Current.User as CustomPrincipal);
                if (cp != null)
                {
                    int     compId   = cp.CompanyID;
                    int     userID   = cp.CurrentUserId;
                    Product oProduct = ProductRepo.getProduct(id, compId).FirstOrDefault();
                    if (oProduct != null)
                    {
                        oProduct.IsActive  = false;
                        oProduct.IsDeleted = true;
                        oProduct.DeletedOn = DateTime.Now;
                        oProduct.DeletedBy = userID;
                        ProductRepo.updateProduct(oProduct);
                        this.ShowMessage(ConstantEnums.MessageType.Success, "Product Deleted Successfully");
                    }
                    else
                    {
                        return(HandleException.CustomException("Delete", "Product"));
                    }

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("Index", "Login"));
                }
            }
            catch (Exception ex)
            {
                return(HandleException.CustomException("Delete", "Product"));
            }
        }
Example #28
0
        /// <summary>
        /// 刷新表格中的数据
        /// </summary>
        /// <returns>ture:成功  false:失败</returns>
        public bool RefreshData()
        {
            try
            {
                PowerEachTotal pet = new PowerEachTotal();
                pet.PowerLineUID = lineuid;
                list.Clear();
                dataTable = new DataTable();
                list      = Services.BaseService.GetList <PowerEachTotal>("SelectPowerEachTotalList", pet);
                dataTable = DataConverter.ToDataTable((IList)list, typeof(PowerEachTotal));
                this.treeList1.DataSource = dataTable;
                this.treeList1.ExpandAll();

                treeList1.MoveFirst();
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return(false);
            }

            return(true);
        }
Example #29
0
        protected bool SaveRecord()
        {
            //创建/修改 对象
            try
            {
                if (IsCreate)
                {
                    Services.BaseService.Create <PSP_ForecastReports>(_obj);
                }
                else
                {
                    Services.BaseService.Update <PSP_ForecastReports>(_obj);
                }
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return(false);
            }

            //操作已成功
            return(true);
        }
Example #30
0
        public bool RefreshData()
        {
            string pjt = " ProjectID='" + MIS.ProgUID + "'";
            IList <PS_Table_AreaWH> lt = Common.Services.BaseService.GetList <PS_Table_AreaWH>("SelectPS_Table_AreaWHByConn", pjt);

            repositoryItemLookUpEdit1.DataSource = lt;
            try
            {
                IList <BurdenLine> list = Services.BaseService.GetList <BurdenLine>("SelectBurdenLineByWhere", " uid like '%" + Itop.Client.MIS.ProgUID + "%' order by BurdenDate");
                //if (indexlist.Count > 0)
                //{
                //    VisibleColumns(indexlist);
                //}
                this.gridControl.DataSource = list;
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return(false);
            }

            return(true);
        }
        public IndexFiles()
        {
            // Build
            var crawlDirTree = new Crawl_directory_tree();
            var compileFiles = new Compile_files(crawlDirTree);

            var readLines = new Read_text_lines();
            var splitLinesIntoWords = new Split_lines_into_words();
            var readWords = new Read_words(readLines, splitLinesIntoWords);

            var filterWords = new Filter_words();
            var extractWords = new Extract_words(readWords, filterWords);

            var compileWords = new Compile_words();
            var writeIndexToFile = new Write_index_to_file();
            var buildIndex = new Build_index(compileWords, writeIndexToFile);

            var logValidationError = new Log<string>(errMsg => "*** " + errMsg);
            var logException = new Log<Exception>(ex => "*** " + ex.Message + '\n' + ex.StackTrace);

            var handleEx = new HandleException<Tuple<string, string>>();

            var asyncCompileFiles = new Asynchronize<Tuple<string, string>>();
            var asyncBuildIndex = new Asynchronize<Tuple<string, string[]>>();

            var countFilesFound = new CountItemsUntilNullForScatter<string>();
            var parExtractWords = new Parallelize<string>();
            var finishStreamOfFileWordsWithNull = new InsertNullAfterItemsForGather<Tuple<string, string[]>>();

            // Bind
            this.in_Process = _ => asyncCompileFiles.In_Process(_);

            asyncCompileFiles.Out_ProcessSequentially += handleEx.In_Process;
            handleEx.Out_Process += compileFiles.In_Process;
            handleEx.Out_Exception += logException.In_Process;

            logException.Out_Data += _ => this.Out_UnhandledException(_);

            compileFiles.Out_FileFound += countFilesFound.In_Count;
            compileFiles.Out_FileFound += filename =>
                                              {
                                                  if (filename != null)
                                                      this.Out_FileFoundToIndex(filename);
                                              };

            countFilesFound.Out_Counted += parExtractWords.In_Process;
            parExtractWords.Out_ProcessInParallel += extractWords.In_Process;

            countFilesFound.Out_Count += finishStreamOfFileWordsWithNull.In_NumberOfItemsToGather;

            extractWords.Out_WordsExtracted += finishStreamOfFileWordsWithNull.In_Process;
            finishStreamOfFileWordsWithNull.Out_Gather += asyncBuildIndex.In_Process;
            asyncBuildIndex.Out_ProcessSequentially += buildIndex.In_Process;

            compileFiles.Out_IndexFilename += buildIndex.In_IndexFilename;

            compileFiles.Out_ValidationError += logValidationError.In_Process;
            logValidationError.Out_Data += _ => this.Out_ValidationError(_);

            buildIndex.Out_Statistics += _ => this.Out_Statistics(_);
        }
Example #32
0
		void InitialiseDelegates()
		{
			 OnCallback += new ParentCallback(InvokeParentCallback);
			 OnException += new HandleException(InvokeHandleException); 
		}