コード例 #1
0
        protected override object GetEditObject()
        {
            if (facade == null)
            {
                facade = new BaseModelFacade(this.DataProvider);
            }
            SoftWareVersion softWareVersion = this.facade.CreateNewSoftWareVersion();

            softWareVersion.VersionCode    = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtSoftWareVersionEdit.Text, 40));
            softWareVersion.Status         = FormatHelper.CleanString(this.rblSoftWareStatusEdit.SelectedValue);
            softWareVersion.EffectiveDate  = FormatHelper.TODateInt(this.dateEffectiveDateEdit.Text);
            softWareVersion.InvalidDate    = FormatHelper.TODateInt(this.dateInvalidDateEdit.Text);
            softWareVersion.MaintainUser   = base.GetUserCode();
            softWareVersion.OrganizationID = GlobalVariables.CurrentOrganizations.First().OrganizationID;

            return(softWareVersion);
        }
コード例 #2
0
        protected void cmdImport_ServerClick(object sender, EventArgs e)
        {
            string fileName = FileLoadProcess.UploadFile2ServerUploadFolder(this.Page, this.fileInit, null);

            if (fileName == null)
            {
                BenQGuru.eMES.Common.ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileIsEmpty");
            }
            if (!fileName.ToLower().EndsWith(".csv"))
            {
                BenQGuru.eMES.Common.ExceptionManager.Raise(this.GetType().BaseType, "$Error_UploadFileTypeError");
            }

            if (items == null)
            {
                items = GetAllItem(fileName);
                if (items == null)
                {
                    return;
                }
            }
            if (items == null || items.Length == 0)
            {
                return;
            }

            int         successNum = 0;
            CultureInfo culture    = new System.Globalization.CultureInfo("en-US");
            string      userCode   = this.GetUserCode();

            if (facade == null)
            {
                facade = new BaseModelFacade(this.DataProvider);
            }

            SoftWareVersion softWareVersion = this.facade.CreateNewSoftWareVersion();

            ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false;
            ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection();
            DataProvider.BeginTransaction();
            try
            {
                for (int i = 0; i < items.Length; i++)
                {
                    #region Check

                    string versionCode = GetFieldValue(items[i], "VersionCode");
                    if (versionCode == string.Empty)
                    {
                        throw new Exception("软件版本不能为空");
                    }
                    else
                    {
                        object obj = facade.GetSoftWareVersion(versionCode);

                        if (obj != null)
                        {
                            throw new Exception(string.Format("软件版本:{0} 已经存在", versionCode));
                        }
                    }

                    if (Encoding.Default.GetByteCount(versionCode) > 40)
                    {
                        throw new Exception("软件版本长度超出范围,最大长度40字节");
                    }

                    string effectiveDate = GetFieldValue(items[i], "EffectiveDate");
                    if (effectiveDate == string.Empty)
                    {
                        throw new Exception("生效日期不能为空");
                    }
                    else
                    {
                        try
                        {
                            DateTime endDate = DateTime.ParseExact(effectiveDate, "yyyyMMdd", culture);
                        }
                        catch
                        {
                            throw new Exception("生效日期格式不正确");
                        }
                    }

                    string invalidDate = GetFieldValue(items[i], "InvalidDate");
                    if (invalidDate == string.Empty)
                    {
                        throw new Exception("失效日期不能为空");
                    }
                    else
                    {
                        try
                        {
                            DateTime endDate = DateTime.ParseExact(invalidDate, "yyyyMMdd", culture);
                        }
                        catch
                        {
                            throw new Exception("失效日期格式不正确");
                        }
                    }

                    #endregion

                    softWareVersion.VersionCode    = versionCode;
                    softWareVersion.Status         = SoftWareVersionStatus.Valid;
                    softWareVersion.EffectiveDate  = int.Parse(effectiveDate);
                    softWareVersion.InvalidDate    = int.Parse(invalidDate);
                    softWareVersion.MaintainUser   = userCode;
                    softWareVersion.OrganizationID = GlobalVariables.CurrentOrganizations.First().OrganizationID;

                    this.facade.AddSoftWareVersion(softWareVersion);

                    successNum++;
                }

                this.DataProvider.CommitTransaction();

                string strMessage = "导入:" + successNum + "笔";
                string alertInfo  =
                    string.Format("<script language=javascript>alert('{0}');</script>", strMessage);
                if (!this.IsClientScriptBlockRegistered("ImportAlert"))
                {
                    this.RegisterClientScriptBlock("ImportAlert", alertInfo);
                }

                items = null;

                this.gridHelper.RequestData();
                this.buttonHelper.PageActionStatusHandle(PageActionType.Query);
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                ExceptionManager.Raise(this.GetType().BaseType, ex.Message);
            }
            finally
            {
                ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = true;
            }
        }
コード例 #3
0
        protected void cmdImport_ServerClick(object sender, EventArgs e)
        {
            string fileName = FileLoadProcess.UploadFile2ServerUploadFolder(this.Page, this.fileInit, null);

            if (fileName == null)
            {
                WebInfoPublish.Publish(this, "$Error_UploadFileIsEmpty", this.languageComponent1);
                return;
            }
            if (!fileName.ToLower().EndsWith(".csv"))
            {
                WebInfoPublish.Publish(this, "$Error_UploadFileTypeError", this.languageComponent1);
                return;
            }

            if (items == null)
            {
                items = GetAllItem(fileName);
                if (items == null)
                {
                    return;
                }
            }
            if (items == null || items.Length == 0)
            {
                return;
            }

            int         successNum = 0;
            CultureInfo culture    = new System.Globalization.CultureInfo("en-US");
            string      userCode   = this.GetUserCode();

            if (facade == null)
            {
                facade = new BaseModelFacade(this.DataProvider);
            }

            SoftWareVersion softWareVersion = this.facade.CreateNewSoftWareVersion();

            ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false;
            ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection();
            DataProvider.BeginTransaction();
            try
            {
                for (int i = 0; i < items.Length; i++)
                {
                    #region Check

                    string versionCode = GetFieldValue(items[i], "VersionCode");
                    if (versionCode == string.Empty)
                    {
                        WebInfoPublish.Publish(this, "软件版本不能为空", this.languageComponent1);
                        return;
                    }
                    else
                    {
                        object obj = facade.GetSoftWareVersion(versionCode);

                        if (obj != null)
                        {
                            WebInfoPublish.Publish(this, string.Format("软件版本:{0} 已经存在", versionCode), this.languageComponent1);
                            return;
                        }
                    }

                    if (Encoding.Default.GetByteCount(versionCode) > 40)
                    {
                        WebInfoPublish.Publish(this, "软件版本长度超出范围,最大长度40字节", this.languageComponent1);
                        return;
                    }

                    string effectiveDate = GetFieldValue(items[i], "EffectiveDate");
                    if (effectiveDate == string.Empty)
                    {
                        WebInfoPublish.Publish(this, "生效日期不能为空", this.languageComponent1);
                        return;
                    }
                    else
                    {
                        try
                        {
                            DateTime endDate = DateTime.ParseExact(effectiveDate, "yyyyMMdd", culture);
                        }
                        catch
                        {
                            WebInfoPublish.Publish(this, "生效日期格式不正确", this.languageComponent1);
                            return;
                        }
                    }

                    string invalidDate = GetFieldValue(items[i], "InvalidDate");
                    if (invalidDate == string.Empty)
                    {
                        WebInfoPublish.Publish(this, "失效日期不能为空", this.languageComponent1);
                        return;
                    }
                    else
                    {
                        try
                        {
                            DateTime endDate = DateTime.ParseExact(invalidDate, "yyyyMMdd", culture);
                        }
                        catch
                        {
                            WebInfoPublish.Publish(this, "失效日期格式不正确", this.languageComponent1);
                            return;
                        }
                    }

                    #endregion

                    softWareVersion.VersionCode    = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(versionCode));
                    softWareVersion.Status         = SoftWareVersionStatus.Valid;
                    softWareVersion.EffectiveDate  = int.Parse(effectiveDate);
                    softWareVersion.InvalidDate    = int.Parse(invalidDate);
                    softWareVersion.MaintainUser   = userCode;
                    softWareVersion.OrganizationID = GlobalVariables.CurrentOrganizations.First().OrganizationID;

                    this.facade.AddSoftWareVersion(softWareVersion);

                    successNum++;
                }

                this.DataProvider.CommitTransaction();

                string strMessage = "导入:" + successNum + "笔";
                WebInfoPublish.Publish(this, strMessage, this.languageComponent1);
                items = null;
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                WebInfoPublish.Publish(this, ex.Message, this.languageComponent1);
                return;
            }
            finally
            {
                ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = true;
            }
        }