//Create SaveFiles form the Building Datas public BuildingData(BuildingManager buildingManager) { GameObject[] gameObjects = buildingManager.buildingObj; isActive = new int[gameObjects.Length]; health = new int[gameObjects.Length]; for (int i = 0; i < gameObjects.Length; i++) { GenerateBase currentBuilding = gameObjects[i].GetComponent <GenerateBase>(); health[i] = currentBuilding.health; if (currentBuilding.Wood.gameObject.activeSelf == false && currentBuilding.Stone.gameObject.activeSelf == false && currentBuilding.Iron.gameObject.activeSelf == false && currentBuilding.Ruin.gameObject.activeSelf == false) { isActive[i] = 0; } else if (currentBuilding.Wood.gameObject.activeSelf == true && currentBuilding.Stone.gameObject.activeSelf == false && currentBuilding.Iron.gameObject.activeSelf == false && currentBuilding.Ruin.gameObject.activeSelf == false) { isActive[i] = 1; } else if (currentBuilding.Wood.gameObject.activeSelf == false && currentBuilding.Stone.gameObject.activeSelf == true && currentBuilding.Iron.gameObject.activeSelf == false && currentBuilding.Ruin.gameObject.activeSelf == false) { isActive[i] = 2; } else if (currentBuilding.Wood.gameObject.activeSelf == false && currentBuilding.Stone.gameObject.activeSelf == false && currentBuilding.Iron.gameObject.activeSelf == false && currentBuilding.Ruin.gameObject.activeSelf == true) { isActive[i] = 3; } else if (currentBuilding.Wood.gameObject.activeSelf == false && currentBuilding.Stone.gameObject.activeSelf == false && currentBuilding.Iron.gameObject.activeSelf == true && currentBuilding.Ruin.gameObject.activeSelf == false) { isActive[i] = 4; } } }
public void getQueueList(ListBox listbox) { int queueid = 0; try { string strSql = ""; if (isLive) { strSql = @" SELECT iid, MsgType, subMsgType, MID, HID, FlightSeq, ResendYN, EDIAddressBook, CustomerId, MsgBody_SITAfreeMSG, MsgAddress_SITAfreeMSG FROM EDI_Msg_Queue WHERE Status = 'W' ORDER BY iid"; //strSql = @" SELECT iid, MsgType, subMsgType, MID, HID, FlightSeq, ResendYN, EDIAddressBook, CustomerId FROM EDI_Msg_Queue WHERE iid = 4326345"; //strSql = @" select * from EDI_Msg_Queue where iid in (9733306)"; //strSql = @" select * from EDI_Msg_Queue where iid in (14397617)"; } else { //strSql = @"select * from EDI_Msg_Queue where Status = 'W' and createddate >= DATEADD(D, 0, DATEDIFF(D, 0, GETDATE())) and Msgtype <> 'Email' order by iid desc"; // strSql = @"select iid, MsgType, subMsgType, MID, HID, FlightSeq, ResendYN, EDIAddressBook, CustomerId, MsgBody_SITAfreeMSG, MsgAddress_SITAfreeMSG // from EDI_Msg_Queue where Status = 'W' and createddate >= DATEADD(D, 0, DATEDIFF(D, 0, GETDATE())) order by iid desc"; //strSql = @" select iid, MsgType, subMsgType, MID, HID, FlightSeq, ResendYN, EDIAddressBook, CustomerId, MsgBody_SITAfreeMSG, MsgAddress_SITAfreeMSG // from EDI_Msg_Queue where iid in (6578241) // "; strSql = @" select * from EDI_Msg_Queue where iid in (14397540)"; //4342600 //strSql = @"select * from EDI_Msg_Queue where Status = 'W' and createddate >= DATEADD(D, 0, DATEDIFF(D, 0, GETDATE())) and Msgtype = 'Email' and submsgtype = 'TTN' order by iid desc"; // strSql = @" select iid, MsgType, subMsgType, MID, HID, FlightSeq, ResendYN, EDIAddressBook, CustomerId, MsgBody_SITAfreeMSG, MsgAddress_SITAfreeMSG // from EDI_Msg_Queue where MsgType = 'FBR' and createddate >= '2016-05-02 14:50'"; } DataTable dt = baseDB.GetSqlDataTable(strSql); string msgReturn = ""; string result = ""; foreach (DataRow dr in dt.Rows) { queueid = Convert.ToInt32(dr["iid"].ToString()); string msgType = dr["MsgType"].ToString().Trim(); string subType = dr["subMsgType"].ToString().Trim(); int mid = 0; try { mid = Convert.ToInt32(dr["MID"].ToString().Trim()); } catch { } int hid = 0; try { hid = Convert.ToInt32(dr["HID"].ToString().Trim()); } catch { } int flightSeq = 0; try { flightSeq = Convert.ToInt32(dr["FlightSeq"].ToString().Trim()); } catch { } string resendYN = dr["ResendYN"].ToString().Trim(); int EDIAddressBook = 0; try { EDIAddressBook = Convert.ToInt32(dr["EDIAddressBook"].ToString().Trim()); } catch { } string CustomerId = dr["CustomerId"].ToString().Trim(); string MsgBody_SITA = dr["MsgBody_SITAfreeMSG"].ToString(); string MsgAddress_SITA = dr["MsgAddress_SITAfreeMSG"].ToString(); //if (msgType != "" && msgType != "Email") // 2016-01-20 In case of Free Text, MsgType can be empty. if (msgType.ToUpper() != "EMAIL") { GenerateBase baseMessage = null; //added. 2015-12-14 if (MsgBody_SITA != null && MsgBody_SITA != string.Empty) { //for send free SITA MSG baseMessage = new sendSITAmsg(); } else { #region Init. if (msgType.ToUpper() == "FSU") { switch (subType.ToUpper()) { case "DLV": baseMessage = new GenerateDLV(); break; case "RCF": case "ARR": baseMessage = new GenerateRCF(); break; case "NFD": case "AWD": baseMessage = new GenerateAWD(); break; case "MAN": case "DEP": baseMessage = new GenerateMAN(); break; //RDS Added 2015-08-12 case "RCS": case "RDS": baseMessage = new GenerateRCS(); break; //RDT Added 2015-08-12 case "RCT": case "RDT": baseMessage = new GenerateRCT(); break; // FOH added. 2016-11-08 case "FOH": baseMessage = new GenerateFOH(); break; case "TFD": baseMessage = new GenerateTFD(); break; } } //NFM added by NA if (msgType.ToUpper() == "NFM") { baseMessage = new GenerateNFM(); } if (msgType.ToUpper() == "FFM") { baseMessage = new GenerateFFM(); } if (msgType.ToUpper() == "IRP") { baseMessage = new GenerateIRP(); } if (msgType.ToUpper() == "FWB") { baseMessage = new GenerateFWB(); } if (msgType.ToUpper() == "FHL") { baseMessage = new GenerateFHL(); } if (msgType.ToUpper() == "FBR") { baseMessage = new GenerateFBR(); } if (msgType.ToUpper() == "UWS") { baseMessage = new GeneratwUWS(); } } #endregion if (baseMessage != null) { //Clear Static Variables baseMessage.msgDestAddrEmail = ""; //added. 2015-12-14 if (MsgBody_SITA != null && MsgBody_SITA != string.Empty) { //for send free SITA MSG msgReturn = MsgBody_SITA; //for email list if (MsgAddress_SITA != null && MsgAddress_SITA != string.Empty) { string[] tmpGetEmail = MsgAddress_SITA.Split(' '); if (tmpGetEmail.Count() > 0) { for (int i = 0; i < tmpGetEmail.Count(); i++) { if (tmpGetEmail[i].IndexOf("@") > -1) { baseMessage.msgDestAddrEmail += tmpGetEmail[i]; baseMessage.msgDestAddrEmail += ";"; } } baseMessage.msgDestAddrEmail = baseMessage.msgDestAddrEmail.TrimEnd(';'); } } } else { if (msgType.ToUpper() == "FHL") { msgReturn = baseMessage.doBuildUp(msgType, subType, hid, flightSeq, queueid); } else { msgReturn = baseMessage.doBuildUp(msgType, subType, mid, flightSeq, queueid); } } if (msgReturn != "") { /* 2014-04-14 * msgReturn = msgReturn.ToUpper(); */ msgReturn = msgReturn.ToUpper().Replace(",", ""); string[] arrMsg = msgReturn.Split('|'); foreach (string msg in arrMsg) { if (ValidationUtil.isThereSitaReciever(msg)) { string test = "good"; } if (isLive) { if (ValidationUtil.isThereSitaReciever(msg)) { result = myMQ.WriteLocalQMsg(msg, MQ_ManagerExp.GR1MQNMRInfo, MQ_ManagerExp.QUEUEID1, MQ_ManagerExp.GR1MQCONInfo, MQ_ManagerExp.GR1MQMInfo); } else { result = "Message sent to successfully"; } } else { result = "Message sent to the queue successfully"; } if (result.IndexOf("successful") > 0) { if (isLive) { baseMessage.UpdateQueue(queueid, "S", ""); //added. 2015-12-14 if (MsgBody_SITA != null && MsgBody_SITA != string.Empty) { baseMessage.InsertLogforFreeSITAmsg(queueid, msg); } else { baseMessage.InsertLog(queueid, msg, msgType, subType); } } else { //baseMessage.UpdateQueue(queueid, "S", ""); //added. 2015-12-14 if (MsgBody_SITA != null && MsgBody_SITA != string.Empty) { baseMessage.InsertLogforFreeSITAmsg(queueid, msg); } else { baseMessage.InsertLog(queueid, msg, msgType, subType); } } //added. 2015-12-14 if (MsgBody_SITA != null && MsgBody_SITA != string.Empty) { } else { //Create Copy to Cargo-Spot Queue if (msgType == "UWS" || msgType == "NFM" || msgType == "FFM" || msgType == "FWB" || (msgType == "FSU" && subType == "DEP") || (msgType == "FSU" && subType == "MAN")) { if (isLive) { if (ValidationUtil.isThereSitaReciever(msg)) { result = myMQ.WriteLocalQMsg(msg, MQ_ManagerExp.GR2MQNMRInfo, MQ_ManagerExp.QUEUEID2, MQ_ManagerExp.GR2MQCONInfo, MQ_ManagerExp.GR2MQMInfo); } } else { } } } } else { baseMessage = new GenerateDLV(); baseMessage.UpdateQueue(queueid, "E", result); buildLog(queueid, result, "CASMqm.WriteLocalQMsg"); } // added on 2017-11-20. requested by Mike 2017-11-20 03:04pm if (isLive) { if (msgType == "FWB" || msgType == "FHL" || msgType == "FHL") { if (baseMessage.msgDestAddrEmail != "") { baseMessage.msgDestAddrEmail += ";[email protected]"; } else { baseMessage.msgDestAddrEmail = "*****@*****.**"; } } } if (baseMessage.msgDestAddrEmail != "") { string emailBody = ""; emailBody = setMSGformat(msgReturn, msgType ?? ""); //emailBody = emailBody.Replace("\r\n", "<br>"); //emailBody = msgReturn.Replace("\r\n", "<br>"); string emailSubj = ""; if (msgType != null && msgType.ToUpper() == "IRP") { emailSubj = "IRP Message: "; emailSubj += baseMessage.IRPSubject ?? ""; } else if (subType != null && subType.Trim() != string.Empty) { emailSubj = msgType.ToUpper() + " - " + subType.ToUpper() + " message"; } else { emailSubj = msgType.ToUpper() + " message"; } if (isLive) { GenerateEmail email = new GenerateEmail(); int emailStatus = 1; try { bool mailSent = baseMail.mailSend(baseMessage.msgDestAddrEmail, emailBody, emailSubj); if (!mailSent) { email.UpdateQueue(queueid, "S", "Error sending email!"); emailStatus = 255; email.UpdateEmailQueue(mid, emailStatus); } } catch (Exception e) { email.UpdateQueue(queueid, "S", "Error sending email!"); emailStatus = 255; email.UpdateEmailQueue(mid, emailStatus); buildLog(queueid, e.Message, e.StackTrace); } } else { bool mailSent = baseMail.mailSend(baseMessage.msgDestAddrEmail, emailBody, emailSubj); } } } } //Clear Static Variables baseMessage.msgDestAddrEmail = ""; } } //Email Sending #region Sending Email if (msgType.ToUpper() == "EMAIL") { GenerateEmail email = new GenerateEmail(); int emailResult; int emailStatus = 1; try { emailResult = email.sendEamil(mid, subType); if (emailResult == 0) { if (resendYN.ToUpper() == "Y") { emailStatus = 3; } email.UpdateQueue(queueid, "S", ""); email.UpdateEmailQueue(mid, emailStatus); if (listbox.Items.Count >= 100) { listbox.Items.Clear(); } listbox.Items.Add(string.Format("Email QueueId:{0} is successfully sent!", mid)); } else { email.UpdateQueue(queueid, "E", "Error sending email!"); emailStatus = 255; email.UpdateEmailQueue(mid, emailStatus); } } catch (Exception e) { email.UpdateQueue(queueid, "E", e.Message); emailStatus = 255; email.UpdateEmailQueue(mid, emailStatus); buildLog(queueid, e.Message, e.StackTrace); } } #endregion } } catch (Exception e) { GenerateBase baseMessage = new GenerateDLV(); baseMessage.UpdateQueue(queueid, "E", e.Message); buildLog(queueid, e.Message, e.StackTrace); } }
/// <summary> /// 生成代码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { GenerateBase generageObj = null; try { var arg = e.Argument as GenerateInfo; var paramList = this.configBllObj.GetParamConfigItem(arg.Language, arg.GroupName, false); List <ParamItem> paramData = paramList == null ? new List <ParamItem>() : paramList.ParamData; switch (arg.HostName) { case "SingleTableHost": generageObj = new SingleTableGenerate(this.nowDb, arg.TableList, arg.TemplateInfos, arg.TypeMapConfigList, arg.NameRuleConfig, paramData, arg.SavePath); break; case "MultTableHost": generageObj = new MultTableGenerate(this.nowDb, arg.TableList, arg.TemplateInfos, arg.TypeMapConfigList, arg.NameRuleConfig, paramData, arg.SavePath); break; case "DatabaseHost": generageObj = new DatabaseGenerate(this.nowDb, arg.TableList, arg.TemplateInfos, arg.TypeMapConfigList, arg.NameRuleConfig, paramData, arg.SavePath); break; default: MsgBox.Show("未知的模板宿主:" + arg.HostName); return; } // check var errMsg = generageObj.CheckParam(); if (String.IsNullOrWhiteSpace(errMsg) == false) { MsgBox.Show(errMsg); return; } // 设置需要生成的总数量 var totalCount = generageObj.GetGenenrateTotalCount(); this.Invoke(new Action(() => { this.progressBar1.Maximum = totalCount; })); generageObj.OnFinishOneGenerateEvent += GenerageObj_OnFinishOneGenerateEvent; Boolean isError = generageObj.Generate(); if (isError) { MsgBox.Show("代码生成出错,具体见输出内容"); } else { MsgBox.Show("生成成功", "提示"); } } catch (Exception e1) { MsgBox.ShowExceptionDialog(e1, "生成出错"); } finally { this.BeginInvoke(new Action(() => { this.UseWaitCursor = false; this.Enabled = true; })); // 注销事件 if (generageObj != null) { generageObj.OnFinishOneGenerateEvent -= GenerageObj_OnFinishOneGenerateEvent; } } }