/// <summary> /// Check device with same logical device id /// </summary> /// <param name="deviceMl"></param> /// <returns></returns> static int CheckForDuplicateId(DeviceModel deviceMl) { StringBuilder objStringBuilderError = new StringBuilder(); int duplicateDevice = 0; //Cannot remove initialization of variable to zero.giving error "Use of unassigned local variable 'duplicateDevice'" try { using (JetstreamClient objMainServiceClient = new JetstreamClient()) { if (objMainServiceClient.GetDeviceModelByLogicalDeviceId(deviceMl) > 0) { duplicateDevice = 1; } } } catch (FaultException<ServiceData> fex) { objStringBuilderError.AppendLine("In method : CheckForDuplicateId(DeviceModel deviceMl) :: DeviceController"); objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", fex.Detail.ErrorMessage, Environment.NewLine); objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, fex.Detail.ErrorDetails); SaveLogger.SaveLoggerError(objStringBuilderError.ToString()); } catch (Exception ex) { objStringBuilderError.AppendLine("In method : CheckForDuplicateId(DeviceModel deviceMl) :: DeviceController"); objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", ex.Message, Environment.NewLine); objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, ex.ToString()); SaveLogger.SaveLoggerError(objStringBuilderError.ToString()); } return duplicateDevice; }