public void Init()
        {
            DataAccessService.Init();
            PrefixDefinitionRepository.Init();
            UnitDefinitionRepository.Init();

            var nullScalar = new ScalarFloat();

            foreach (var prefixDefinition in PrefixDefinitionRepository.GetPrefixDefinitions())
            {
                try
                {
                    UnitService.AddPrefix(prefixDefinition.Name, prefixDefinition.Symbol, "user", nullScalar.GetNewFromFloat(prefixDefinition.Factor) as ScalarFloat, prefixDefinition.Inverted);
                }
                catch
                {
                }
            }
            foreach (var unitDefinition in UnitDefinitionRepository.GetUnitDefinitions())
            {
                try
                {
                    var unit = UnitService.Parse(unitDefinition.Definition);
                    UnitService.AddUnit(unit, unitDefinition.Name, unitDefinition.Symbol, "user");
                }
                catch
                {
                }
            }
        }
Example #2
0
 private void Start()
 {
     _renderers = GetComponentsInChildren <SpriteRenderer>();
     if (startupUnitData)
     {
         Initialize(startupUnitData, owner);
         _unitService.AddUnit(this);
     }
 }
        public void CreateNewUnit(string name, string symbol, string definiton)
        {
            var unit = UnitService.Parse(definiton);

            UnitService.AddUnit(unit, name, symbol, "user");
            UnitDefinitionRepository.AddUnitDefinition(new UnitDefinition {
                Name = name, Symbol = symbol, Definition = unit.AsString
            });
        }
Example #4
0
        public async Task <IActionResult> AddBuilding([FromBody] Unit unit)
        {
            try
            {
                await _unitService.AddUnit(unit);
            }
            catch (ArgumentException e)
            {
                ModelState.AddModelError("Exception", e.Message);
                return(BadRequest(ModelState));
            }

            return(Ok());
        }
Example #5
0
        private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SelectedToolButton(this.保存ToolStripMenuItem);
            Code.Services.LeadService service = new Code.Services.LeadService();
            string name   = txtYHXM.Text.Trim();
            string msbgdz = txtMSBGDZ.Text.Trim();
            string mscz   = txtMSCZ.Text.Trim();
            string mshj   = txtMSHJ.Text.Trim();
            string msxm   = txtMSName.Text.Trim();
            string mspj   = txtMSPJ.Text.Trim();
            string mssj   = txtMSSJ.Text.Trim();
            string mszzdz = txtMSZZDZ.Text.Trim();
            string mark1  = txtRemark.Text.Trim();
            string mark2  = txtUpdateRecord.Text.Trim();
            string unitpy = txtUnitPY.Text.Trim();
            string yhbgdz = txtYHBGDZ.Text.Trim();
            string yhbghj = txtYHBGHJ.Text.Trim();
            string yhbgpj = txtYHBGPJ.Text.Trim();
            string yhcz   = txtYHCZ.Text.Trim();
            string yhsj   = txtYHSJ.Text.Trim();
            string yhssdz = txtYHSSDZ.Text.Trim();
            string yhxmjp = txtYHXMJP.Text.Trim();
            string yhzshj = txtYHZSHJ.Text.Trim();
            string yhzspj = txtYHZSPJ.Text.Trim();
            string yhzw   = txtZW.Text.Trim();
            string area   = cbbArea.SelectedIndex == -1 ? "" : cbbArea.SelectedValue.ToString();
            string unitID = cbbUnit.SelectedIndex == -1 ? "0" : cbbUnit.SelectedValue.ToString();


            if (yhbghj != "")
            {
                Result r = service.CheckRedPhoneIsExists(yhbghj);
                if (r.Status != ResultStatus.Success)
                {
                    if (MessageBox.Show(r.Message + ",是否继续保存?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
                    {
                        this.txtYHBGHJ.Text = "";
                        this.txtYHBGHJ.Focus();
                        return;
                    }
                }
            }
            if (unitID == "0" && cbbUnit.Text.Trim() == "")
            {
                MessageBox.Show("请选择单位或者输入新的单位名称", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else if (unitID == "0" && cbbUnit.Text.Trim() != "")
            {
                Code.Services.UnitService uService = new UnitService();
                unitID = uService.AddUnit(cbbUnit.Text.Trim(), txtUnitPY.Text.Trim(), cbbArea.Text.Trim()).ToString();
            }

            int res = 0;

            if (Status == 0)
            {
                StringBuilder sb = new StringBuilder(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                sb.Append("  [" + CacheStrategy.Instance.GetObject(CacheKey.RealName) + "]");
                sb.Append("建立信息");
                mark2        = sb.ToString();
                res          = service.AddLead(name, int.Parse(unitID), yhzw, yhbgdz, yhbgpj, yhsj, yhbghj, yhzshj, yhssdz, "0", yhxmjp, mark1, mark2, "0", "", msxm, mshj, mspj, mssj, mscz, mszzdz, yhcz, msbgdz, "", yhzspj);
                CurrentModel = service.GetModel(res);
                //CurrentModel.ID = res;
            }
            else if (Status == 2)
            {
                StringBuilder sb = new StringBuilder(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                sb.Append("  [" + CacheStrategy.Instance.GetObject(CacheKey.RealName) + "]");
                sb.Append("更新信息\r\n");
                //sb.Append(txtUnitPY.Text == currentRow["Pinyin"].ToString()? "" : "秘书传真:" + currentRow["SecretaryFax"].ToString() + " -> " + txtMSCZ.Text.Trim() + "\r\n");
                // sb.Append(txtUpdateRecord.Text == currentRow["Mark2"].ToString()? "" : "秘书传真:" + currentRow["SecretaryFax"].ToString() + " -> " + txtMSCZ.Text.Trim() + "\r\n");
                //sb.Append(unitID == currentRow["DepartmentID"].ToString() ? "" : "单位:" + UnitName(currentRow["DepartmentID"].ToString()) + " -> " + cbbUnit.Text + "\r\n");

                //sb.Append(txtYHXM.Text == currentRow["Name"].ToString() ? "" : "姓名:" + currentRow["Name"].ToString() + " -> " + txtYHXM.Text.Trim() + "\r\n");
                //sb.Append(txtZW.Text == currentRow["Duty"].ToString() ? "" : "职务:" + currentRow["Duty"].ToString() + " -> " + txtZW.Text.Trim() + "\r\n");
                //sb.Append(txtYHXMJP.Text == currentRow["NamePinyin"].ToString() ? "" : "姓名简拼:" + currentRow["NamePinyin"].ToString() + " -> " + txtYHXMJP.Text.Trim() + "\r\n");
                //sb.Append(txtYHBGHJ.Text == currentRow["OfficeRedPhone"].ToString() ? "" : "办公红机:" + currentRow["OfficeRedPhone"].ToString() + " -> " + txtYHBGHJ.Text.Trim() + "\r\n");
                //sb.Append(txtYHZSHJ.Text == currentRow["DormitoryRedPhone"].ToString() ? "" : "住宿红机:" + currentRow["DormitoryRedPhone"].ToString() + " -> " + txtYHZSHJ.Text.Trim() + "\r\n");
                //sb.Append(txtYHBGPJ.Text == currentRow["Phone"].ToString() ? "" : "办公普机:" + currentRow["Phone"].ToString() + " -> " + txtYHBGPJ.Text.Trim() + "\r\n");
                //sb.Append(txtYHZSPJ.Text == currentRow["DormitoryPhone"].ToString() ? "" : "住宿普机:" + currentRow["DormitoryPhone"].ToString() + " -> " + txtYHZSPJ.Text.Trim() + "\r\n");
                //sb.Append(txtYHSJ.Text == currentRow["AnyCall"].ToString() ? "" : "手机:" + currentRow["AnyCall"].ToString() + " -> " + txtYHSJ.Text.Trim() + "\r\n");
                //sb.Append(txtYHCZ.Text == currentRow["FAX"].ToString() ? "" : "传真:" + currentRow["FAX"].ToString() + " -> " + txtYHCZ.Text.Trim() + "\r\n");
                //sb.Append(txtYHBGDZ.Text == currentRow["OfficeAddress"].ToString() ? "" : "办公地址:" + currentRow["OfficeAddress"].ToString() + " -> " + txtYHBGDZ.Text.Trim() + "\r\n");
                //sb.Append(txtYHSSDZ.Text == currentRow["DormitoryAddress"].ToString() ? "" : "宿舍地址:" + currentRow["DormitoryAddress"].ToString() + " -> " + txtYHSSDZ.Text.Trim() + "\r\n");
                //sb.Append(txtMSName.Text == currentRow["Secretary"].ToString() ? "" : "秘书姓名:" + currentRow["Secretary"].ToString() + " -> " + txtMSName.Text.Trim() + "\r\n");
                //sb.Append(txtMSHJ.Text == currentRow["SecretaryRedPhone"].ToString() ? "" : "秘书红机:" + currentRow["SecretaryRedPhone"].ToString() + " -> " + txtMSHJ.Text.Trim() + "\r\n");
                //sb.Append(txtMSPJ.Text == currentRow["SecretaryDormitoryRedPhone"].ToString() ? "" : "秘书普机:" + currentRow["SecretaryDormitoryRedPhone"].ToString() + " -> " + txtMSPJ.Text.Trim() + "\r\n");
                //sb.Append(txtMSSJ.Text == currentRow["SecretaryAnyCall"].ToString() ? "" : "秘书手机:" + currentRow["SecretaryAnyCall"].ToString() + " -> " + txtMSSJ.Text.Trim() + "\r\n");
                //sb.Append(txtMSCZ.Text == currentRow["SecretaryFax"].ToString() ? "" : "秘书传真:" + currentRow["SecretaryFax"].ToString() + " -> " + txtMSCZ.Text.Trim() + "\r\n");
                //sb.Append(txtMSBGDZ.Text == currentRow["SecretaryAddress"].ToString() ? "" : "秘书办公地址:" + currentRow["SecretaryAddress"].ToString() + " -> " + txtMSBGDZ.Text.Trim() + "\r\n");
                //sb.Append(txtMSZZDZ.Text == currentRow["SecretaryDormitoryAddress"].ToString() ? "" : "秘书住宅地址:" + currentRow["SecretaryDormitoryAddress"].ToString() + " -> " + txtMSZZDZ.Text.Trim() + "\r\n");

                sb.Append(unitID == CurrentModel.DepartmentID.ToString() ? "" : "单位:" + CurrentModel.DepartmentName + " -> " + cbbUnit.Text + "\r\n");

                sb.Append(txtYHXM.Text == CurrentModel.AName ? "" : "姓名:" + CurrentModel.AName + " -> " + txtYHXM.Text.Trim() + "\r\n");
                sb.Append(txtZW.Text == CurrentModel.Duty ? "" : "职务:" + CurrentModel.Duty + " -> " + txtZW.Text.Trim() + "\r\n");
                sb.Append(txtYHXMJP.Text == CurrentModel.NamePinyin ? "" : "姓名简拼:" + CurrentModel.NamePinyin + " -> " + txtYHXMJP.Text.Trim() + "\r\n");
                sb.Append(txtYHBGHJ.Text == CurrentModel.OfficeRedPhone ? "" : "办公红机:" + CurrentModel.OfficeRedPhone + " -> " + txtYHBGHJ.Text.Trim() + "\r\n");
                sb.Append(txtYHZSHJ.Text == CurrentModel.DormitoryRedPhone ? "" : "住宿红机:" + CurrentModel.DormitoryRedPhone + " -> " + txtYHZSHJ.Text.Trim() + "\r\n");
                sb.Append(txtYHBGPJ.Text == CurrentModel.Phone ? "" : "办公普机:" + CurrentModel.Phone + " -> " + txtYHBGPJ.Text.Trim() + "\r\n");
                sb.Append(txtYHZSPJ.Text == CurrentModel.DormitoryPhone ? "" : "住宿普机:" + CurrentModel.DormitoryPhone + " -> " + txtYHZSPJ.Text.Trim() + "\r\n");
                sb.Append(txtYHSJ.Text == CurrentModel.AnyCall ? "" : "手机:" + CurrentModel.AnyCall + " -> " + txtYHSJ.Text.Trim() + "\r\n");
                sb.Append(txtYHCZ.Text == CurrentModel.Fax ? "" : "传真:" + CurrentModel.Fax + " -> " + txtYHCZ.Text.Trim() + "\r\n");
                sb.Append(txtYHBGDZ.Text == CurrentModel.OfficeAddress ? "" : "办公地址:" + CurrentModel.OfficeAddress + " -> " + txtYHBGDZ.Text.Trim() + "\r\n");
                sb.Append(txtYHSSDZ.Text == CurrentModel.DormitoryAddress ? "" : "宿舍地址:" + CurrentModel.DormitoryAddress + " -> " + txtYHSSDZ.Text.Trim() + "\r\n");
                sb.Append(txtMSName.Text == CurrentModel.Secretary ? "" : "秘书姓名:" + CurrentModel.Secretary + " -> " + txtMSName.Text.Trim() + "\r\n");
                sb.Append(txtMSHJ.Text == CurrentModel.SecretaryRedPhone ? "" : "秘书红机:" + CurrentModel.SecretaryRedPhone + " -> " + txtMSHJ.Text.Trim() + "\r\n");
                sb.Append(txtMSPJ.Text == CurrentModel.SecretaryDormitoryRedPhone ? "" : "秘书普机:" + CurrentModel.SecretaryDormitoryRedPhone + " -> " + txtMSPJ.Text.Trim() + "\r\n");
                sb.Append(txtMSSJ.Text == CurrentModel.SecretaryAnyCall ? "" : "秘书手机:" + CurrentModel.SecretaryAnyCall + " -> " + txtMSSJ.Text.Trim() + "\r\n");
                sb.Append(txtMSCZ.Text == CurrentModel.SecretaryFax ? "" : "秘书传真:" + CurrentModel.SecretaryFax + " -> " + txtMSCZ.Text.Trim() + "\r\n");
                sb.Append(txtMSBGDZ.Text == CurrentModel.SecretaryAddress ? "" : "秘书办公地址:" + CurrentModel.SecretaryAddress + " -> " + txtMSBGDZ.Text.Trim() + "\r\n");
                sb.Append(txtMSZZDZ.Text == CurrentModel.SecretaryDormitoryAddress ? "" : "秘书住宅地址:" + CurrentModel.SecretaryDormitoryAddress + " -> " + txtMSZZDZ.Text.Trim() + "\r\n");

                //sb.Append(txtRemark.Text == currentRow["Mark1"].ToString() ? "" : "备注:" + currentRow["Mark1"].ToString() + " -> " + txtRemark.Text.Trim() + "\r\n");


                mark2 = sb.ToString() + mark2;
                txtUpdateRecord.Text = mark2;
                int code = CurrentModel.Code == null ? 0 : (int)CurrentModel.Code;
                res = Convert.ToInt32(service.UpdateLead(CurrentModel.ID, name, int.Parse(unitID), yhzw, yhbgdz, yhbgpj, yhsj, yhbghj, yhzshj, yhssdz, code, yhxmjp, mark1, mark2, "0", "", msxm, mshj, mspj, mssj, mscz, mszzdz, yhcz, msbgdz, "", yhzspj));
            }
            else
            {
            }
            if (res > 0)
            {
                if (Status == 0)
                {
                    MessageBox.Show("保存成功,用户在最后一条记录,尚未排序!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("保存成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                if (OnQueryListHandler != null)
                {
                    OnQueryListHandler(CurrentModel.ID);
                }
            }
            else
            {
                MessageBox.Show("保存失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }