private void ManintainGeneralProfile(ref string option1I, ref ArrayScreenNameValue arrayFields,
            Screen.OperationContext opSheet, Screen.ScreenService proxySheet, Screen.ScreenSubmitRequestDTO requestSheet,
            ref Screen.ScreenDTO replySheet, int currentRow, out string profile, out string profileType,
            out string fuelOilType2I, out string fuelCapacity2I)
        {
            option1I = option1I.Substring(0, 1);
            profileType = "" + _cells.GetCell("B" + currentRow).Value;
            profile = "" + _cells.GetCell("C" + currentRow).Value;
            fuelOilType2I = "" + _cells.GetCell("D" + currentRow).Value;
            fuelCapacity2I = "" + _cells.GetCell("E" + currentRow).Value;

            _eFunctions.RevertOperation(opSheet, proxySheet);
            replySheet = proxySheet.executeScreen(opSheet, "MSO615");

            if (replySheet.mapName == "MSM615A" && _excelApp.ActiveWorkbook.ActiveSheet.Name == _sheetName01)
            {
                arrayFields = new ArrayScreenNameValue();
                arrayFields.Add("OPTION1I", option1I);

                if (profileType == "EGI")
                {
                    arrayFields.Add("GROUP_ID11I", profile);
                }
                else
                {
                    arrayFields.Add("PLANT_NO11I", profile);
                }

                requestSheet.screenFields = arrayFields.ToArray();
                requestSheet.screenKey = "1";
                replySheet = proxySheet.submit(opSheet, requestSheet);

                if (_eFunctions.CheckReplyWarning(replySheet))
                    replySheet = proxySheet.submit(opSheet, requestSheet);

                if (replySheet != null && replySheet.mapName == "MSM617B" && !_eFunctions.CheckReplyError(replySheet))
                {
                    arrayFields = new ArrayScreenNameValue();

                    arrayFields.Add("PLANT_NO2I", profile);
                    arrayFields.Add("FUEL_OIL_TYPE2I", fuelOilType2I);
                    arrayFields.Add("FUEL_CAPACITY2I", fuelCapacity2I);
                    arrayFields.Add("VAL_PROF_FLG2I", "N");

                    requestSheet.screenFields = arrayFields.ToArray();
                    requestSheet.screenKey = "1";
                    replySheet = proxySheet.submit(opSheet, requestSheet);

                    if (replySheet != null && replySheet.mapName == "MSM617B" &&
                        (replySheet.functionKeys.Contains("XMIT-Confirm") || _eFunctions.CheckReplyWarning(replySheet)))
                    {
                        replySheet = proxySheet.submit(opSheet, requestSheet);

                        if (replySheet != null && replySheet.mapName == "MSM615A" &&
                            !_eFunctions.CheckReplyWarning(replySheet) && !_eFunctions.CheckReplyError(replySheet))
                        {
                            _cells.GetCell("A" + currentRow + ":" + "C" + currentRow).Style =
                                _cells.GetStyle(StyleConstants.Success);
                        }
                    }
                    else if (_eFunctions.CheckReplyError(replySheet))
                    {
                        _cells.GetCell("A" + currentRow + ":" + "B" + currentRow).Style =
                            _cells.GetStyle(StyleConstants.Error);
                        _cells.GetCell("A" + currentRow).AddComment(_cells.GetEmptyIfNull(replySheet.message));
                    }
                    else
                    {
                        _cells.GetCell("A" + currentRow + ":" + "C" + currentRow).Style =
                            _cells.GetStyle(StyleConstants.Success);
                    }
                }
                else if (_eFunctions.CheckReplyError(replySheet))
                {
                    _cells.GetCell("A" + currentRow + ":" + "B" + currentRow).Style = _cells.GetStyle(StyleConstants.Error);
                    _cells.GetCell("A" + currentRow).AddComment(_cells.GetEmptyIfNull(replySheet.message));
                }
                else
                {
                    _cells.GetCell("A" + currentRow + ":" + "B" + currentRow).Style = _cells.GetStyle(StyleConstants.Error);
                    _cells.GetCell("A" + currentRow).AddComment("NPI");
                }
            }
        }
        private void DeleteProfile(ref string OPTION1I, ref ArrayScreenNameValue arrayFields,
            Screen.OperationContext opSheet, Screen.ScreenService proxySheet, Screen.ScreenSubmitRequestDTO requestSheet,
            ref Screen.ScreenDTO replySheet, int currentRow, out string PROFILE, out string PROFILE_TYPE)
        {
            OPTION1I = "3";
            PROFILE_TYPE = "" + _cells.GetCell("B" + currentRow).Value;
            PROFILE = "" + _cells.GetCell("C" + currentRow).Value;

            _eFunctions.RevertOperation(opSheet, proxySheet);
            replySheet = proxySheet.executeScreen(opSheet, "MSO615");

            if (replySheet.mapName == "MSM615A" && _excelApp.ActiveWorkbook.ActiveSheet.Name == _sheetName01)
            {
                arrayFields = new ArrayScreenNameValue();
                arrayFields.Add("OPTION1I", OPTION1I);

                if (PROFILE_TYPE == "EGI")
                {
                    arrayFields.Add("GROUP_ID11I", PROFILE);
                }
                else
                {
                    arrayFields.Add("PLANT_NO11I", PROFILE);
                }

                requestSheet.screenFields = arrayFields.ToArray();
                requestSheet.screenKey = "1";
                replySheet = proxySheet.submit(opSheet, requestSheet);

                if (_eFunctions.CheckReplyWarning(replySheet))
                    replySheet = proxySheet.submit(opSheet, requestSheet);

                if (replySheet != null && replySheet.mapName == "MSM617A" && !_eFunctions.CheckReplyError(replySheet))
                {
                    arrayFields = new ArrayScreenNameValue();

                    arrayFields.Add("EQUIP_REF1I", PROFILE);

                    requestSheet.screenFields = arrayFields.ToArray();
                    requestSheet.screenKey = "9";
                    replySheet = proxySheet.submit(opSheet, requestSheet);

                    if (_eFunctions.CheckReplyWarning(replySheet))
                        replySheet = proxySheet.submit(opSheet, requestSheet);

                    while (replySheet.mapName == "MSM180B")
                    {
                        arrayFields = new ArrayScreenNameValue();
                        arrayFields.Add("DELETE_CONF2I", "Y");

                        requestSheet.screenFields = arrayFields.ToArray();
                        requestSheet.screenKey = "1";
                        replySheet = proxySheet.submit(opSheet, requestSheet);
                    }

                    if (replySheet != null && replySheet.mapName == "MSM615A" && !_eFunctions.CheckReplyError(replySheet))
                    {
                        _cells.GetCell("A" + currentRow + ":" + "C" + currentRow).Style =
                            _cells.GetStyle(StyleConstants.Success);
                    }
                    else if (_eFunctions.CheckReplyError(replySheet))
                    {
                        _cells.GetCell("A" + currentRow + ":" + "B" + currentRow).Style =
                            _cells.GetStyle(StyleConstants.Error);
                        _cells.GetCell("A" + currentRow).AddComment(_cells.GetEmptyIfNull(replySheet.message));
                    }
                    else
                    {
                        _cells.GetCell("A" + currentRow + ":" + "B" + currentRow).Style =
                            _cells.GetStyle(StyleConstants.Error);
                        _cells.GetCell("A" + currentRow).AddComment("NPI");
                    }
                }
            }
        }
        private void MaintainStatisticsProfile(ref string option1I, List<string> statType, List<string> statEntry,
            ref ArrayScreenNameValue arrayFields, Screen.OperationContext opSheet, Screen.ScreenService proxySheet,
            Screen.ScreenSubmitRequestDTO requestSheet, ref Screen.ScreenDTO replySheet, int currentRow,
            out string profile, out string profileType, out string prStatType1I)
        {
            option1I = option1I.Substring(0, 1);
            profileType = "" + _cells.GetCell("B" + currentRow).Value;
            profile = "" + _cells.GetCell("C" + currentRow).Value;
            prStatType1I = "" + _cells.GetCell("F" + currentRow).Value;

            statType = new List<string>();
            statEntry = new List<string>();

            const int startColumn = 7;
            for (var i = 0; i < 20; i++)
            {
                statType.Add(_cells.GetEmptyIfNull(_cells.GetCell(i*2 + startColumn, currentRow).Value));
                statEntry.Add(_cells.GetEmptyIfNull(_cells.GetCell(i*2 + startColumn + 1, currentRow).Value));
            }

            _eFunctions.RevertOperation(opSheet, proxySheet);
            replySheet = proxySheet.executeScreen(opSheet, "MSO615");

            if (replySheet.mapName != "MSM615A" || _excelApp.ActiveWorkbook.ActiveSheet.Name != _sheetName01) return;
            arrayFields = new ArrayScreenNameValue();
            arrayFields.Add("OPTION1I", option1I);
            arrayFields.Add(profileType == "EGI" ? "GROUP_ID11I" : "PLANT_NO11I", profile);

            requestSheet.screenFields = arrayFields.ToArray();
            requestSheet.screenKey = "1";
            replySheet = proxySheet.submit(opSheet, requestSheet);

            if (_eFunctions.CheckReplyWarning(replySheet))
                replySheet = proxySheet.submit(opSheet, requestSheet);

            if (replySheet != null && replySheet.mapName == "MSM617A")
            {
                arrayFields = new ArrayScreenNameValue();

                arrayFields.Add("EQUIP_REF1I", profile);
                arrayFields.Add("PR_STAT_TYPE1I", prStatType1I);

                double index = 0;
                double firstIndex;
                double secondIndex;
                foreach (var item in statType)
                {
                    firstIndex = (index%2) + 1;
                    secondIndex = Math.Ceiling((index + 1)/2);
                    arrayFields.Add("STAT_TYPE" + firstIndex + "1I" + secondIndex, item);
                    index++;
                }

                index = 0;
                foreach (var item in statEntry)
                {
                    firstIndex = (index%2) + 1;
                    secondIndex = Math.Ceiling((index + 1)/2);
                    arrayFields.Add("STAT_ENTRY" + firstIndex + "1I" + secondIndex, item);
                    index++;
                }

                requestSheet.screenFields = arrayFields.ToArray();
                requestSheet.screenKey = "1";
                replySheet = proxySheet.submit(opSheet, requestSheet);

                while (replySheet != null && replySheet.mapName == "MSM617A" &&
                       (replySheet.functionKeys.Contains("XMIT-Confirm") ||
                        replySheet.functionKeys.Contains("XMIT-Validate") ||
                        _eFunctions.CheckReplyWarning(replySheet)))
                {
                    replySheet = proxySheet.submit(opSheet, requestSheet);
                }

                if (replySheet != null && replySheet.mapName == "MSM615A")
                {
                    _cells.GetCell("A" + currentRow + ":" + "C" + currentRow).Style =
                        _cells.GetStyle(StyleConstants.Success);
                }
                else if (_eFunctions.CheckReplyError(replySheet))
                {
                    _cells.GetCell("A" + currentRow + ":" + "B" + currentRow).Style =
                        _cells.GetStyle(StyleConstants.Error);
                    _cells.GetCell("A" + currentRow).AddComment(_cells.GetEmptyIfNull(replySheet.message));
                }
                else
                {
                    _cells.GetCell("A" + currentRow + ":" + "B" + currentRow).Style =
                        _cells.GetStyle(StyleConstants.Error);
                    _cells.GetCell("A" + currentRow).AddComment("NPI");
                }
            }
            else if (_eFunctions.CheckReplyError(replySheet))
            {
                _cells.GetCell("A" + currentRow + ":" + "B" + currentRow).Style = _cells.GetStyle(StyleConstants.Error);
                _cells.GetCell("A" + currentRow).AddComment(_cells.GetEmptyIfNull(replySheet.message));
            }
            else
            {
                _cells.GetCell("A" + currentRow + ":" + "B" + currentRow).Style = _cells.GetStyle(StyleConstants.Error);
                _cells.GetCell("A" + currentRow).AddComment("NPI");
            }
        }